Skip to content

Commit

Permalink
Merge branch 'tests' of github.com:JuliaGeometry/MeshIntegrals.jl int…
Browse files Browse the repository at this point in the history
…o tests
  • Loading branch information
mikeingold committed Dec 6, 2024
2 parents 4a512ac + 0d7ab73 commit 20081d8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
42 changes: 29 additions & 13 deletions test/combinations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ This file includes tests for:
end
end

function runtests(testable::TestableGeometry, supports::SupportStatus; rtol=sqrt(eps()))
function runtests(
testable::TestableGeometry,
supports::SupportStatus;
rtol = sqrt(eps())
)
# Test alias functions
for alias in (lineintegral, surfaceintegral, volumeintegral)
# if supports.alias
Expand All @@ -87,20 +91,32 @@ This file includes tests for:
if supported
# Scalar integrand
sol = testable.solution
@test integral(testable.integrand, testable.geometry, rule) sol rtol=rtol
@test integral(testable.integrand, testable.geometry, rule)sol rtol=rtol

# Callable integrand
f = Callable(testable.integrand)
@test integral(f, testable.geometry, rule) sol rtol=rtol
@test integral(f, testable.geometry, rule)sol rtol=rtol

# Vector integrand
fv(p) = fill(testable.integrand(p), 3)
sol_v = fill(testable.solution, 3)
@test integral(fv, testable.geometry, rule) sol_v rtol=rtol
@test integral(fv, testable.geometry, rule)sol_v rtol=rtol
else
@test_throws "not supported" integral(testable.integrand, testable.geometry, rule)
end # if
f = testable.integrand
geometry = testable.geometry
@test_throws "not supported" integral(f, geometry, rule)
end
end # for

#=
iter_diff_methods = (
(supports.autoenzyme, AutoEnzyme()),
)
for (supported, diff_method) in iter_diff_methods
@test integral(testable.integrand, testable.geometry; diff_method=diff_method)≈sol rtol=rtol
end
=#
end # function
end #testsnippet

Expand Down Expand Up @@ -162,7 +178,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, curve, solution)
runtests(testable, SupportStatus(:line); rtol=0.5e-2)
runtests(testable, SupportStatus(:line); rtol = 0.5e-2)
end

@testitem "Meshes.Box 1D" setup=[Combinations] begin
Expand All @@ -179,7 +195,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, box, solution)
runtests(testable, SupportStatus(:line); rtol=1e-6)
runtests(testable, SupportStatus(:line); rtol = 1e-6)
end

@testitem "Meshes.Box 2D" setup=[Combinations] begin
Expand All @@ -195,7 +211,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, box, solution)
runtests(testable, SupportStatus(:surface); rtol=1e-6)
runtests(testable, SupportStatus(:surface); rtol = 1e-6)
end

@testitem "Meshes.Box 3D" setup=[Combinations] begin
Expand All @@ -212,7 +228,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, box, solution)
runtests(testable, SupportStatus(:volume); rtol=1e-6)
runtests(testable, SupportStatus(:volume); rtol = 1e-6)
end

@testitem "Meshes.Circle" setup=[Combinations] begin
Expand Down Expand Up @@ -271,7 +287,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, cone, solution)
runtests(testable, SupportStatus(:surface); rtol=1e-6)
runtests(testable, SupportStatus(:surface); rtol = 1e-6)
end

@testitem "Meshes.Cylinder" setup=[Combinations] begin
Expand Down Expand Up @@ -338,7 +354,7 @@ end
# Package and run tests
# Tolerances are higher due to `measure` being only an approximation
testable = TestableGeometry(integrand, ellipsoid, solution)
runtests(testable, SupportStatus(:surface); rtol=1e-2)
runtests(testable, SupportStatus(:surface); rtol = 1e-2)
end

@testitem "Meshes.FrustumSurface" setup=[Combinations] begin
Expand Down Expand Up @@ -370,7 +386,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, frustum, solution)
runtests(testable, SupportStatus(:surface); rtol=1e-6)
runtests(testable, SupportStatus(:surface); rtol = 1e-6)
end

@testitem "Meshes.Hexahedron" setup=[Combinations] begin
Expand Down
2 changes: 1 addition & 1 deletion test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
@test FiniteDifference().ε 1e-6

# Test jacobian with wrong number of parametric coordinates
box = Box(Point(0, 0), Point(1, 1))
box = Box(Point(0, 0), Point(1, 1))
@test_throws ArgumentError jacobian(box, zeros(3))
end

Expand Down

0 comments on commit 20081d8

Please sign in to comment.