Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LasNikas committed May 11, 2023
1 parent 91435f2 commit 8256798
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
62 changes: 62 additions & 0 deletions test/unit/setups/merge_shapes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 2D
@testset "Merge Shapes 2D" begin
@testset "Rectangular Shapes" begin
shape_1 = RectangularShape(0.1, (3, 4), (-1.0, 1.0), 1.0)
shape_2 = RectangularShape(0.05, (3, 4), (0.0, 1.0), 1.0)
shape_3 = RectangularShape(0.2, (3, 4), (0.0, 0.0), 1.0)

expected_coords_1 = [-1.0 -1.0 -1.0 -1.0 -0.9 -0.9 -0.9 -0.9 -0.8 -0.8 -0.8 -0.8 0.0 0.0 0.0 0.0 0.05 0.05 0.05 0.05 0.1 0.1 0.1 0.1;
1.0 1.1 1.2 1.3 1.0 1.1 1.2 1.3 1.0 1.1 1.2 1.3 1.0 1.05 1.1 1.15 1.0 1.05 1.1 1.15 1.0 1.05 1.1 1.15]
expected_coords_2 = [-1.0 -1.0 -1.0 -1.0 -0.9 -0.9 -0.9 -0.9 -0.8 -0.8 -0.8 -0.8 0.0 0.0 0.0 0.0 0.05 0.05 0.05 0.05 0.1 0.1 0.1 0.1 0.0 0.0 0.0 0.0 0.2 0.2 0.2 0.2 0.4 0.4 0.4 0.4;
1.0 1.1 1.2 1.3 1.0 1.1 1.2 1.3 1.0 1.1 1.2 1.3 1.0 1.05 1.1 1.15 1.0 1.05 1.1 1.15 1.0 1.05 1.1 1.15 0.0 0.2 0.4 0.6 0.0 0.2 0.4 0.6 0.0 0.2 0.4 0.6]
merged_shapes = MergeShapes(shape_1, shape_2)
@test merged_shapes.coordinates expected_coords_1

merged_shapes = MergeShapes(shape_1, shape_2, shape_3)
@test merged_shapes.coordinates expected_coords_2
end

@testset "Circular Shapes" begin
shape_1 = CircularShape(0.1, 0.5, (-1.0, 1.0), 1.0)
shape_2 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1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.05 1.05 1.05 1.05 1.05 1.05 1.05 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.15 1.15 1.15 1.15 1.15 1.2]

expected_coords_2 = [-1.2 -1.1 -1.0 -0.9 -0.8 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -0.6 -1.4 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 -1.3 -1.2 -1.1 -1.0 -0.9 -0.8 -0.7 0.0 -0.1 -0.05 0.0 0.05 0.1 -0.15000000000000002 -0.1 -0.05 0.0 0.05 0.1 0.15000000000000002 -0.15000000000000002 -0.1 -0.05 0.0 0.05 0.1 0.15000000000000002 -0.15000000000000002 -0.1 -0.05 0.0 0.05 0.1 0.15000000000000002 -0.15000000000000002 -0.1 -0.05 0.0 0.05 0.1 0.15000000000000002 -0.15000000000000002 -0.1 -0.05 0.0 0.05 0.1 0.15000000000000002 -0.1 -0.05 0.0 0.05 0.1 0.0 -0.3 -0.15 0.0 0.15 0.3 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 -0.8999999999999999 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 0.8999999999999999 -0.8999999999999999 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 0.8999999999999999 -0.8999999999999999 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 0.8999999999999999 -0.8999999999999999 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 0.8999999999999999 -0.8999999999999999 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 0.8999999999999999 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 -0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 0.75 -0.6 -0.44999999999999996 -0.3 -0.15 0.0 0.15 0.3 0.44999999999999996 0.6 -0.3 -0.15 0.0 0.15 0.3;
0.6 0.6 0.6 0.6 0.6 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.4 1.4 1.4 1.4 1.4 1.4 1.4 0.8 0.85 0.85 0.85 0.85 0.85 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.95 0.95 0.95 0.95 0.95 0.95 0.95 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.05 1.05 1.05 1.05 1.05 1.05 1.05 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.15 1.15 1.15 1.15 1.15 1.2 -1.0999999999999999 -1.0999999999999999 -1.0999999999999999 -1.0999999999999999 -1.0999999999999999 -0.95 -0.95 -0.95 -0.95 -0.95 -0.95 -0.95 -0.95 -0.95 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.6499999999999999 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.35 -0.35 -0.35 -0.35 -0.35 -0.35 -0.35 -0.35 -0.35 -0.35 -0.35 -0.35 -0.35 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 -0.05000000000000002 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.09999999999999998 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.24999999999999994 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.39999999999999997 0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.7 0.7 0.7 0.7 0.7]

merged_shapes = MergeShapes(shape_1, shape_2)
@test merged_shapes.coordinates expected_coords_1

merged_shapes = MergeShapes(shape_1, shape_2, shape_3)
@test merged_shapes.coordinates expected_coords_2
end

@testset "Mixed Shapes" begin
shape_1 = CircularShape(0.1, 0.8, (0.0, 1.0), 1.0)
shape_2 = RectangularShape(0.05, (3, 4), (-0.5, 0.0), 1.0)

expected_coords = [-0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 -0.7000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 -0.7000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 -0.7000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 -0.7000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 -0.7000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 -0.7000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 -0.7000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 0.7000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 -0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6000000000000001 -0.5 -0.4 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 0.4 0.5 -0.30000000000000004 -0.2 -0.1 0.0 0.1 0.2 0.30000000000000004 -0.5 -0.5 -0.5 -0.5 -0.45 -0.45 -0.45 -0.45 -0.4 -0.4 -0.4 -0.4;
0.29999999999999993 0.29999999999999993 0.29999999999999993 0.29999999999999993 0.29999999999999993 0.29999999999999993 0.29999999999999993 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.3999999999999999 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 0.9 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.3 1.4 1.4 1.4 1.4 1.4 1.4 1.4 1.4 1.4 1.4 1.4 1.4 1.4 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.6 1.6 1.6 1.6 1.6 1.6 1.6 1.6 1.6 1.6 1.6 1.7000000000000002 1.7000000000000002 1.7000000000000002 1.7000000000000002 1.7000000000000002 1.7000000000000002 1.7000000000000002 0.0 0.05 0.1 0.15000000000000002 0.0 0.05 0.1 0.15000000000000002 0.0 0.05 0.1 0.15000000000000002]

merged_shapes = MergeShapes(shape_1, shape_2)
@test merged_shapes.coordinates expected_coords
end
end

# 3D
@testset "Merge Shapes 3D" begin
@testset "Rectangular Shapes" begin
shape_1 = RectangularShape(0.1, (3, 4, 2), (-1.0, 1.0, 0.1), 1.0)
shape_2 = RectangularShape(0.05, (3, 4, 5), (-0.5, 0.0, -0.2), 1.0)

expected_coords = [-1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -0.9 -0.9 -0.9 -0.9 -0.9 -0.9 -0.9 -0.9 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.8 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.45 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4 -0.4;
1.0 1.0 1.1 1.1 1.2 1.2 1.3 1.3 1.0 1.0 1.1 1.1 1.2 1.2 1.3 1.3 1.0 1.0 1.1 1.1 1.2 1.2 1.3 1.3 0.0 0.0 0.0 0.0 0.0 0.05 0.05 0.05 0.05 0.05 0.1 0.1 0.1 0.1 0.1 0.15000000000000002 0.15000000000000002 0.15000000000000002 0.15000000000000002 0.15000000000000002 0.0 0.0 0.0 0.0 0.0 0.05 0.05 0.05 0.05 0.05 0.1 0.1 0.1 0.1 0.1 0.15000000000000002 0.15000000000000002 0.15000000000000002 0.15000000000000002 0.15000000000000002 0.0 0.0 0.0 0.0 0.0 0.05 0.05 0.05 0.05 0.05 0.1 0.1 0.1 0.1 0.1 0.15000000000000002 0.15000000000000002 0.15000000000000002 0.15000000000000002 0.15000000000000002;
0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 0.1 0.2 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0 -0.2 -0.15000000000000002 -0.1 -0.04999999999999999 0.0]

merged_shapes = MergeShapes(shape_1, shape_2)
@test merged_shapes.coordinates expected_coords
end
end
1 change: 1 addition & 0 deletions test/unit/setups/setups.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include("rectangular_shape.jl")
include("circular_shape.jl")
include("rectangular_tank.jl")
include("merge_shapes.jl")

0 comments on commit 8256798

Please sign in to comment.