Skip to content

Commit

Permalink
Added some basic tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
aptmcl committed Mar 25, 2024
1 parent 5e88a35 commit 5e4b607
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions test/Test.jl
Original file line number Diff line number Diff line change
@@ -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



2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ using KhepriBase
using Test

@testset "KhepriBase.jl" begin
# Write your tests here.
include("Test.jl")
end

0 comments on commit 5e4b607

Please sign in to comment.