Skip to content

Commit

Permalink
One testsnippet per file
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeingold committed Dec 8, 2024
1 parent e04b75b commit 49473ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
11 changes: 8 additions & 3 deletions test/floating_point_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
# have expected level of accuracy and are produce results in appropriate type

# Base value for atol when integrating with a particular FP type
@testsnippet BaseAtol begin

@testsnippet FP_Types begin
using LinearAlgebra: norm
using Meshes
using Unitful

baseatol = Dict(
Float32 => 0.01f0,
BigFloat => BigFloat(0.001)
)
end

@testitem "Alternate floating types" setup=[Setup, BaseAtol] begin
@testitem "Alternate floating types" setup=[FP_Types] begin
@testset "$FP" for FP in (Float32, BigFloat)
# Rectangular volume with unit integrand
f = p -> one(FP)
Expand Down Expand Up @@ -41,7 +46,7 @@ end
end
end

@testitem "Integral Aliases" setup=[Setup] begin
@testitem "Integral Aliases" setup=[FP_Types] begin
f = p -> one(Float32)
box1d = Box(Point(fill(0.0f0u"m", 1)...), Point(fill(1.0f0u"m", 1)...))
box2d = Box(Point(fill(0.0f0u"m", 2)...), Point(fill(1.0f0u"m", 2)...))
Expand Down
6 changes: 0 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ using TestItems

# For CI, run all tests not marked with the :extended tag
@run_package_tests filter=ti -> !(:extended in ti.tags) verbose=true

@testsnippet Setup begin
using LinearAlgebra: norm
using Meshes
using Unitful
end
16 changes: 8 additions & 8 deletions test/utils.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
@testitem "Utilities" setup=[Setup] begin
@testsnippet Utils begin
using LinearAlgebra: norm
using MeshIntegrals: _units, _zeros, _ones
using Meshes
using MeshIntegrals: _default_diff_method, _parametric, _units, _zeros, _ones
using Unitful
end

@testitem "Utilities" setup=[Utils] begin
# _KVector
v = Meshes.Vec(3, 4)
@test norm(MeshIntegrals._KVector(v)) 5.0u"m"
Expand All @@ -19,9 +23,7 @@
@test _ones(Float32, 2) == (1.0f0, 1.0f0)
end

@testitem "Differentiation" setup=[Setup] begin
using MeshIntegrals: _default_diff_method

@testitem "Differentiation" setup=[Utils] begin
# _default_diff_method
sphere = Sphere(Point(0, 0, 0), 1.0)
@test _default_diff_method(Meshes.Sphere) isa FiniteDifference
Expand All @@ -35,9 +37,7 @@ end
@test_throws ArgumentError jacobian(box, zeros(3))
end

@testitem "_ParametricGeometry" setup=[Setup] begin
using MeshIntegrals: _parametric

@testitem "_ParametricGeometry" setup=[Utils] begin
pt_n = Point(0, 3, 0)
pt_w = Point(-7, 0, 0)
pt_e = Point(8, 0, 0)
Expand Down

0 comments on commit 49473ad

Please sign in to comment.