Skip to content

Commit 443b9bc

Browse files
eliascarvjuliohmgithub-actions[bot]
authored
Use TestItems.jl (#1024)
* Use TestItems.jl * Minor adjusts * More adjustments * More adjustments * More adjustments * More fixes * More fixes * More fixes * More fixes * Update test/primitives.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/sampling.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/transforms.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/transforms.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update test/traversing.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * More fixes * Adjust CI.yml * Adjust CY.yml * Adjust CI.yml * Adjust runtests.jl --------- Co-authored-by: Júlio Hoffimann <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent d2348d0 commit 443b9bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+10183
-10289
lines changed

.github/workflows/CI.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
JULIA_NUM_THREADS: 2
1717
jobs:
1818
test:
19-
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
19+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.float }} - ${{ github.event_name }}
2020
runs-on: ${{ matrix.os }}
2121
strategy:
2222
fail-fast: false
@@ -30,6 +30,9 @@ jobs:
3030
- windows-latest
3131
arch:
3232
- x64
33+
float:
34+
- Float32
35+
- Float64
3336
steps:
3437
- uses: actions/checkout@v4
3538
- uses: julia-actions/setup-julia@v2
@@ -48,6 +51,8 @@ jobs:
4851
${{ runner.os }}-
4952
- uses: julia-actions/julia-buildpkg@v1
5053
- uses: julia-actions/julia-runtest@v1
54+
env:
55+
FLOAT_TYPE: ${{ matrix.float }}
5156
- uses: julia-actions/julia-processcoverage@v1
5257
- uses: codecov/codecov-action@v4
5358
with:

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1515
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1616
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
1717
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
18+
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
19+
TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe"
1820
TransformsBase = "28dd2a49-a57a-4bfb-84ca-1a49db9b96b8"
1921
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

test/boundingboxes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Bounding boxes" begin
1+
@testitem "Bounding boxes" setup = [Setup] begin
22
p = cart(0, 0)
33
@test boundingbox(p) == Box(p, p)
44
@test @allocated(boundingbox(p)) < 50

test/clamping.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Clamping" begin
1+
@testitem "Clamping" setup = [Setup] begin
22
box = Box((zero(T), zero(T)), (one(T), one(T)))
33
@test clamp(cart(0.5, 0.5), box) == cart(0.5, 0.5)
44
@test clamp(cart(-1, 0.5), box) == cart(0, 0.5)

test/clipping.jl

Lines changed: 68 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,76 @@
1-
@testset "Clipping" begin
2-
@testset "SutherlandHodgman" begin
3-
# triangle
4-
poly = Triangle(cart(6, 2), cart(3, 5), cart(0, 2))
5-
other = Quadrangle(cart(5, 0), cart(5, 4), cart(0, 4), cart(0, 0))
6-
clipped = clip(poly, other, SutherlandHodgman())
7-
@test issimple(clipped)
8-
@test all(vertices(clipped) .≈ [cart(5, 3), cart(4, 4), cart(2, 4), cart(0, 2), cart(5, 2)])
1+
@testitem "SutherlandHodgman" setup = [Setup] begin
2+
# triangle
3+
poly = Triangle(cart(6, 2), cart(3, 5), cart(0, 2))
4+
other = Quadrangle(cart(5, 0), cart(5, 4), cart(0, 4), cart(0, 0))
5+
clipped = clip(poly, other, SutherlandHodgman())
6+
@test issimple(clipped)
7+
@test all(vertices(clipped) .≈ [cart(5, 3), cart(4, 4), cart(2, 4), cart(0, 2), cart(5, 2)])
98

10-
# octagon
11-
poly = Octagon(cart(8, -2), cart(8, 5), cart(2, 5), cart(4, 3), cart(6, 3), cart(4, 1), cart(2, 1), cart(2, -2))
12-
other = Quadrangle(cart(5, 0), cart(5, 4), cart(0, 4), cart(0, 0))
13-
clipped = clip(poly, other, SutherlandHodgman())
14-
@test !issimple(clipped)
15-
@test all(
16-
vertices(clipped) .≈
17-
[cart(3, 4), cart(4, 3), cart(5, 3), cart(5, 2), cart(4, 1), cart(2, 1), cart(2, 0), cart(5, 0), cart(5, 4)]
18-
)
9+
# octagon
10+
poly = Octagon(cart(8, -2), cart(8, 5), cart(2, 5), cart(4, 3), cart(6, 3), cart(4, 1), cart(2, 1), cart(2, -2))
11+
other = Quadrangle(cart(5, 0), cart(5, 4), cart(0, 4), cart(0, 0))
12+
clipped = clip(poly, other, SutherlandHodgman())
13+
@test !issimple(clipped)
14+
@test all(
15+
vertices(clipped) .≈
16+
[cart(3, 4), cart(4, 3), cart(5, 3), cart(5, 2), cart(4, 1), cart(2, 1), cart(2, 0), cart(5, 0), cart(5, 4)]
17+
)
1918

20-
# inside
21-
poly = Quadrangle(cart(1, 0), cart(1, 1), cart(0, 1), cart(0, 0))
22-
other = Quadrangle(cart(5, 0), cart(5, 4), cart(0, 4), cart(0, 0))
23-
clipped = clip(poly, other, SutherlandHodgman())
24-
@test issimple(clipped)
25-
@test all(vertices(clipped) .≈ vertices(poly))
19+
# inside
20+
poly = Quadrangle(cart(1, 0), cart(1, 1), cart(0, 1), cart(0, 0))
21+
other = Quadrangle(cart(5, 0), cart(5, 4), cart(0, 4), cart(0, 0))
22+
clipped = clip(poly, other, SutherlandHodgman())
23+
@test issimple(clipped)
24+
@test all(vertices(clipped) .≈ vertices(poly))
2625

27-
# outside
28-
poly = Quadrangle(cart(7, 6), cart(7, 7), cart(6, 7), cart(6, 6))
29-
other = Quadrangle(cart(5, 0), cart(5, 4), cart(0, 4), cart(0, 0))
30-
clipped = clip(poly, other, SutherlandHodgman())
31-
@test isnothing(clipped)
26+
# outside
27+
poly = Quadrangle(cart(7, 6), cart(7, 7), cart(6, 7), cart(6, 6))
28+
other = Quadrangle(cart(5, 0), cart(5, 4), cart(0, 4), cart(0, 0))
29+
clipped = clip(poly, other, SutherlandHodgman())
30+
@test isnothing(clipped)
3231

33-
# surrounded
34-
poly = Hexagon(cart(0, 2), cart(-2, 2), cart(-2, 0), cart(0, -2), cart(2, -2), cart(2, 0))
35-
other = Hexagon(cart(1, 0), cart(0, 1), cart(-1, 1), cart(-1, 0), cart(0, -1), cart(1, -1))
36-
clipped = clip(poly, other, SutherlandHodgman())
37-
@test issimple(clipped)
38-
@test all(vertices(clipped) .≈ vertices(other))
32+
# surrounded
33+
poly = Hexagon(cart(0, 2), cart(-2, 2), cart(-2, 0), cart(0, -2), cart(2, -2), cart(2, 0))
34+
other = Hexagon(cart(1, 0), cart(0, 1), cart(-1, 1), cart(-1, 0), cart(0, -1), cart(1, -1))
35+
clipped = clip(poly, other, SutherlandHodgman())
36+
@test issimple(clipped)
37+
@test all(vertices(clipped) .≈ vertices(other))
3938

40-
# PolyArea with box
41-
outer = Ring(cart(8, 0), cart(4, 8), cart(2, 8), cart(-2, 0), cart(0, 0), cart(1, 2), cart(5, 2), cart(6, 0))
42-
inner = Ring(cart(4, 4), cart(2, 4), cart(3, 6))
43-
poly = PolyArea([outer, inner])
44-
other = Box(cart(0, 1), cart(3, 7))
45-
clipped = clip(poly, other, SutherlandHodgman())
46-
crings = rings(clipped)
47-
@test !issimple(clipped)
48-
@test all(
49-
vertices(crings[1]) .≈
50-
[cart(1.5, 7.0), cart(0.0, 4.0), cart(0.0, 1.0), cart(0.5, 1.0), cart(1.0, 2.0), cart(3.0, 2.0), cart(3.0, 7.0)]
51-
)
52-
@test all(vertices(crings[2]) .≈ [cart(3.0, 4.0), cart(2.0, 4.0), cart(3.0, 6.0)])
39+
# PolyArea with box
40+
outer = Ring(cart(8, 0), cart(4, 8), cart(2, 8), cart(-2, 0), cart(0, 0), cart(1, 2), cart(5, 2), cart(6, 0))
41+
inner = Ring(cart(4, 4), cart(2, 4), cart(3, 6))
42+
poly = PolyArea([outer, inner])
43+
other = Box(cart(0, 1), cart(3, 7))
44+
clipped = clip(poly, other, SutherlandHodgman())
45+
crings = rings(clipped)
46+
@test !issimple(clipped)
47+
@test all(
48+
vertices(crings[1]) .≈
49+
[cart(1.5, 7.0), cart(0.0, 4.0), cart(0.0, 1.0), cart(0.5, 1.0), cart(1.0, 2.0), cart(3.0, 2.0), cart(3.0, 7.0)]
50+
)
51+
@test all(vertices(crings[2]) .≈ [cart(3.0, 4.0), cart(2.0, 4.0), cart(3.0, 6.0)])
5352

54-
# PolyArea with outer ring outside and inner ring inside
55-
outer = Ring(cart(8, 0), cart(2, 6), cart(-4, 0))
56-
inner = Ring(cart(1, 3), cart(3, 3), cart(3, 1), cart(1, 1))
57-
poly = PolyArea([outer, inner])
58-
other = Quadrangle(cart(4, 4), cart(0, 4), cart(0, 0), cart(4, 0))
59-
clipped = clip(poly, other, SutherlandHodgman())
60-
@test !issimple(clipped)
61-
crings = rings(clipped)
62-
@test all(vertices(crings[1]) .≈ vertices(other))
63-
@test all(vertices(crings[2]) .≈ vertices(inner))
53+
# PolyArea with outer ring outside and inner ring inside
54+
outer = Ring(cart(8, 0), cart(2, 6), cart(-4, 0))
55+
inner = Ring(cart(1, 3), cart(3, 3), cart(3, 1), cart(1, 1))
56+
poly = PolyArea([outer, inner])
57+
other = Quadrangle(cart(4, 4), cart(0, 4), cart(0, 0), cart(4, 0))
58+
clipped = clip(poly, other, SutherlandHodgman())
59+
@test !issimple(clipped)
60+
crings = rings(clipped)
61+
@test all(vertices(crings[1]) .≈ vertices(other))
62+
@test all(vertices(crings[2]) .≈ vertices(inner))
6463

65-
# PolyArea with one inner ring inside `other` and another inner ring outside `other`
66-
outer = Ring(cart(6, 4), cart(6, 7), cart(1, 6), cart(1, 1), cart(5, 2))
67-
inner₁ = Ring(cart(3, 3), cart(3, 4), cart(4, 3))
68-
inner₂ = Ring(cart(2, 5), cart(2, 6), cart(3, 5))
69-
poly = PolyArea([outer, inner₁, inner₂])
70-
other = PolyArea(Ring(cart(6, 1), cart(7, 2), cart(6, 5), cart(0, 2), cart(1, 1)))
71-
clipped = clip(poly, other, SutherlandHodgman())
72-
crings = rings(clipped)
73-
@test !issimple(clipped)
74-
@test length(crings) == 2
75-
@test all(vertices(crings[1]) .≈ [cart(6, 4), cart(6, 5), cart(1, 2.5), cart(1, 1), cart(5, 2)])
76-
@test all(vertices(crings[2]) .≈ [cart(3.0, 3.0), cart(3.0, 3.5), cart(10 / 3, 11 / 3), cart(4.0, 3.0)])
77-
end
64+
# PolyArea with one inner ring inside `other` and another inner ring outside `other`
65+
outer = Ring(cart(6, 4), cart(6, 7), cart(1, 6), cart(1, 1), cart(5, 2))
66+
inner₁ = Ring(cart(3, 3), cart(3, 4), cart(4, 3))
67+
inner₂ = Ring(cart(2, 5), cart(2, 6), cart(3, 5))
68+
poly = PolyArea([outer, inner₁, inner₂])
69+
other = PolyArea(Ring(cart(6, 1), cart(7, 2), cart(6, 5), cart(0, 2), cart(1, 1)))
70+
clipped = clip(poly, other, SutherlandHodgman())
71+
crings = rings(clipped)
72+
@test !issimple(clipped)
73+
@test length(crings) == 2
74+
@test all(vertices(crings[1]) .≈ [cart(6, 4), cart(6, 5), cart(1, 2.5), cart(1, 1), cart(5, 2)])
75+
@test all(vertices(crings[2]) .≈ [cart(3.0, 3.0), cart(3.0, 3.5), cart(10 / 3, 11 / 3), cart(4.0, 3.0)])
7876
end

test/coarsening.jl

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
@testset "Coarsening" begin
2-
@testset "RegularCoarsening" begin
3-
# 2D grids
4-
grid = CartesianGrid(cart(0.0, 0.0), cart(10.0, 10.0), dims=(20, 20))
5-
tgrid = CartesianGrid(cart(0.0, 0.0), cart(10.0, 10.0), dims=(10, 10))
6-
@test coarsen(grid, RegularCoarsening(2)) == tgrid
7-
rgrid = convert(RectilinearGrid, grid)
8-
trgrid = convert(RectilinearGrid, tgrid)
9-
@test coarsen(rgrid, RegularCoarsening(2)) == trgrid
10-
sgrid = convert(StructuredGrid, grid)
11-
tsgrid = convert(StructuredGrid, tgrid)
12-
@test coarsen(sgrid, RegularCoarsening(2)) == tsgrid
13-
tfgrid = TransformedGrid(grid, Identity())
14-
@test coarsen(tfgrid, RegularCoarsening(2)) == coarsen(grid, RegularCoarsening(2))
1+
@testitem "RegularCoarsening" setup = [Setup] begin
2+
# 2D grids
3+
grid = CartesianGrid(cart(0.0, 0.0), cart(10.0, 10.0), dims=(20, 20))
4+
tgrid = CartesianGrid(cart(0.0, 0.0), cart(10.0, 10.0), dims=(10, 10))
5+
@test coarsen(grid, RegularCoarsening(2)) == tgrid
6+
rgrid = convert(RectilinearGrid, grid)
7+
trgrid = convert(RectilinearGrid, tgrid)
8+
@test coarsen(rgrid, RegularCoarsening(2)) == trgrid
9+
sgrid = convert(StructuredGrid, grid)
10+
tsgrid = convert(StructuredGrid, tgrid)
11+
@test coarsen(sgrid, RegularCoarsening(2)) == tsgrid
12+
tfgrid = TransformedGrid(grid, Identity())
13+
@test coarsen(tfgrid, RegularCoarsening(2)) == coarsen(grid, RegularCoarsening(2))
1514

16-
grid = CartesianGrid(cart(0.0, 0.0), cart(10.0, 10.0), dims=(20, 20))
17-
tgrid = CartesianGrid(cart(0.0, 0.0), cart(10.0, 10.0), dims=(10, 5))
18-
@test coarsen(grid, RegularCoarsening(2, 4)) == tgrid
15+
grid = CartesianGrid(cart(0.0, 0.0), cart(10.0, 10.0), dims=(20, 20))
16+
tgrid = CartesianGrid(cart(0.0, 0.0), cart(10.0, 10.0), dims=(10, 5))
17+
@test coarsen(grid, RegularCoarsening(2, 4)) == tgrid
1918

20-
# 3D grids
21-
grid = cartgrid(100, 100, 100)
22-
tgrid = CartesianGrid(minimum(grid), maximum(grid), dims=(50, 25, 20))
23-
@test coarsen(grid, RegularCoarsening(2, 4, 5)) == tgrid
24-
rgrid = convert(RectilinearGrid, grid)
25-
trgrid = convert(RectilinearGrid, tgrid)
26-
@test coarsen(rgrid, RegularCoarsening(2, 4, 5)) == trgrid
27-
sgrid = convert(StructuredGrid, grid)
28-
tsgrid = convert(StructuredGrid, tgrid)
29-
@test coarsen(sgrid, RegularCoarsening(2, 4, 5)) == tsgrid
30-
tfgrid = TransformedGrid(grid, Identity())
31-
@test coarsen(tfgrid, RegularCoarsening(2, 4, 5)) == coarsen(grid, RegularCoarsening(2, 4, 5))
32-
end
19+
# 3D grids
20+
grid = cartgrid(100, 100, 100)
21+
tgrid = CartesianGrid(minimum(grid), maximum(grid), dims=(50, 25, 20))
22+
@test coarsen(grid, RegularCoarsening(2, 4, 5)) == tgrid
23+
rgrid = convert(RectilinearGrid, grid)
24+
trgrid = convert(RectilinearGrid, tgrid)
25+
@test coarsen(rgrid, RegularCoarsening(2, 4, 5)) == trgrid
26+
sgrid = convert(StructuredGrid, grid)
27+
tsgrid = convert(StructuredGrid, tgrid)
28+
@test coarsen(sgrid, RegularCoarsening(2, 4, 5)) == tsgrid
29+
tfgrid = TransformedGrid(grid, Identity())
30+
@test coarsen(tfgrid, RegularCoarsening(2, 4, 5)) == coarsen(grid, RegularCoarsening(2, 4, 5))
3331
end

test/complement.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "complement" begin
1+
@testitem "Complement of geometries" setup = [Setup] begin
22
τ = atol(T)
33

44
t = Triangle(cart(0, 0), cart(1, 0), cart(1, 1))

test/connectivities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Connectivities" begin
1+
@testitem "Connectivities" setup = [Setup] begin
22
# basic tests
33
c = connect((1, 2, 3), Triangle)
44
@test pltype(c) == Triangle

0 commit comments

Comments
 (0)