Skip to content

Commit

Permalink
Add test for hcubature_print where io unspecified
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeingold committed Dec 15, 2024
1 parent 8552700 commit 7339678
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ end
end

@testset "print" begin
# Capture println's in a buffer, ensure one printed line per integrand eval
let io = IOBuffer()
# Capture println's in a buffer, ensure one line per integrand function eval
(i, e, count) = hcubature_print(io, x -> 2, (0,0), (2pi, pi))
regex = r"f\((?<x>.+?)\) = (?<y>.+?)"
io_lines = collect(eachmatch(regex, String(take!(io))))
@test i 4pi^2
@test length(io_lines) == count
end

# Test wrapper without io specified
(i, e, count) = hcubature_print(x -> 2, (0,0), (2pi, pi));
@test i 4pi^2
end

# function wrapper for counting evaluations
Expand Down

0 comments on commit 7339678

Please sign in to comment.