From 5e4b6078ad8268ac32ca1e28c75b5b5dc8c336a2 Mon Sep 17 00:00:00 2001 From: Antonio Menezes Leitao Date: Mon, 25 Mar 2024 17:14:59 +0000 Subject: [PATCH] Added some basic tests. --- test/Test.jl | 33 +++++++++++++++++++++++++++++++++ test/runtests.jl | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/Test.jl diff --git a/test/Test.jl b/test/Test.jl new file mode 100644 index 0000000..7f1129c --- /dev/null +++ b/test/Test.jl @@ -0,0 +1,33 @@ +using Test +using KhepriBase + +@testset "Coordinate conversions" begin + @test pol(1, 0).x == 1 + @test pol(1, 0).y == 0 + @test pol(1, π/2).x ≈ 0 atol=1e-9 + @test pol(1, π/2).y == 1 + @test pol(1, π).x == -1 + @test pol(1, π).y == 0 + @test pol(1, 3π/2).x ≈ 0 atol=1e-9 + @test pol(1, 3π/2).y == -1 +end + +@testset "Paths" begin + @test coincident_path_location(pol(1, π/2), xy(0,1)) + with(path_tolerance, 1e-15) do + @test coincident_path_location(pol(1, π/2), xy(0,1)) + end + with(path_tolerance, 1e-20) do + @test ! coincident_path_location(pol(1, π/2), xy(0,1)) + end + + @test is_closed_path(circular_path()) + + @test path_domain(circular_path()) == (0, 2π) + @test path_domain(arc_path()) == (0, π*1) # The nasty π problem. + @test path_domain(polygonal_path(x(0), x(2))) == (0, 2) + @test path_domain(polygonal_path(x(0), x(2), xy(2, 3))) == (0, 5) +end + + + diff --git a/test/runtests.jl b/test/runtests.jl index feb5470..91b69ed 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,5 +2,5 @@ using KhepriBase using Test @testset "KhepriBase.jl" begin - # Write your tests here. + include("Test.jl") end