Skip to content

Commit

Permalink
Updated dist testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Mattheus-Moerman committed Mar 3, 2024
1 parent e8288aa commit 61f35b4
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,33 @@ using Test, Comodo, GeometryBasics

@testset "dist" verbose = true begin

v1 = Float64[0, 0, 0]
v2 = Float64[0, 0, 5]

result = dist(v1, v2)
@testset "vector to vector" begin
v1 = Float64[0, 0, 0]
v2 = Float64[0, 0, 5]
result = dist(v1, v2)
@test result == [0.0 0.0 5.0; 0.0 0.0 5.0; 0.0 0.0 5.0]
end

@test result == [0.0 0.0 5.0; 0.0 0.0 5.0; 0.0 0.0 5.0]
@testset "vector of points to vector of points" begin
V1 = Vector{GeometryBasics.Point{3, Float64}}(undef,4)
V1[1 ] = GeometryBasics.Point{3, Float64}( 1.0, 0.0, 0.0)
V1[2 ] = GeometryBasics.Point{3, Float64}( 0.0, 1.0, 0.0)
V1[3 ] = GeometryBasics.Point{3, Float64}( 0.0, 0.0, 1.0)
V1[4 ] = GeometryBasics.Point{3, Float64}( 1.0, 1.0, 1.0)

V2 = Vector{GeometryBasics.Point{3, Float64}}(undef,3)
V2[1 ] = GeometryBasics.Point{3, Float64}( π, 0.0, 0.0)
V2[2 ] = GeometryBasics.Point{3, Float64}( 0.0, π, 0.0)
V2[3 ] = GeometryBasics.Point{3, Float64}( 0.0, 0.0, π)

result = dist(V1, V2)
eps_level = maximum(eps.(result))

@test isapprox(result,[2.141592653589793 3.296908309475615 3.296908309475615;
3.296908309475615 2.141592653589793 3.296908309475615;
3.296908309475615 3.296908309475615 2.141592653589793;
2.5664019743426345 2.5664019743426345 2.5664019743426345],atol=eps_level)
end
end

@testset "gridpoints" verbose = true begin
Expand Down

0 comments on commit 61f35b4

Please sign in to comment.