Mercurial > repos > public > sbplib_julia
diff test/Grids/geometry_test.jl @ 1969:7f4a5146c84c feature/grids/geometry_functions
Add tests and better constructor for Circle
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 14 Feb 2025 08:23:00 +0100 |
parents | 35cb503985b6 |
children | 8e9575b518a1 |
line wrap: on
line diff
--- a/test/Grids/geometry_test.jl Wed Feb 12 15:45:37 2025 +0100 +++ b/test/Grids/geometry_test.jl Fri Feb 14 08:23:00 2025 +0100 @@ -1,5 +1,5 @@ using Diffinitive.Grids -using Diffinitive.Grids: Line, LineSegment, linesegments, polygon_edges +using Diffinitive.Grids: Line, LineSegment, linesegments, polygon_edges, Circle using StaticArrays @testset "Line" begin @@ -85,9 +85,33 @@ @testset "Circle" begin @testset "Constructors" begin + @test Circle([1,2], 1) isa Circle{SVector{2,Int},Int} + @test Circle([1,2], 1.) isa Circle{SVector{2,Int},Float64} + @test Circle([1,2.], 1.) isa Circle{SVector{2,Float64},Float64} + @test Circle([1,2.], 1) isa Circle{SVector{2,Float64},Int} + @test Circle((1,2.), 1.) isa Circle{SVector{2,Float64},Float64} + @test Circle((1,2), 1.) isa Circle{SVector{2,Int},Float64} + @test Circle((1.,2), 1) isa Circle{SVector{2,Float64},Int} + @test Circle((1,2), 1) isa Circle{SVector{2,Int},Int} + @test Circle(@SVector[1,2], 1.) isa Circle{SVector{2,Int},Float64} + @test Circle(@SVector[1,2.], 1.) isa Circle{SVector{2,Float64},Float64} end - @test_broken false + @testset "Evaluation" begin + c = Circle([0,0], 1) + @test c(0) ≈ [1,0] + @test c(π/2) ≈ [0,1] + @test c(π) ≈ [-1,0] + @test c(3π/2) ≈ [0,-1] + @test c(π/4) ≈ [1/√(2),1/√(2)] + + c = Circle([0,0], 2) + @test c(0) ≈ [2,0] + @test c(π/2) ≈ [0,2] + @test c(π) ≈ [-2,0] + @test c(3π/2) ≈ [0,-2] + @test c(π/4) ≈ [√(2),√(2)] + end end @testset "TransfiniteInterpolationSurface" begin