From 61f35b481add4be52ac642b4129581032821d9b9 Mon Sep 17 00:00:00 2001 From: Kevin-Mattheus-Moerman Date: Sun, 3 Mar 2024 12:06:03 +0000 Subject: [PATCH] Updated dist testing --- test/runtests.jl | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 21c0b51..dabaf0f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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