diff test/Grids/geometry_test.jl @ 1966:478b233999c5 feature/grids/geometry_functions

Add tests and better constructors for Line
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 12 Feb 2025 15:33:48 +0100
parents eedb5d7b90b4
children 669361a8195a
line wrap: on
line diff
--- a/test/Grids/geometry_test.jl	Wed Feb 12 15:30:47 2025 +0100
+++ b/test/Grids/geometry_test.jl	Wed Feb 12 15:33:48 2025 +0100
@@ -1,6 +1,25 @@
+using Diffinitive.Grids
+using Diffinitive.Grids: Line
+using StaticArrays
+
 @testset "Line" begin
-    @test_broken false
     @testset "Constructors" begin
+        @test Line([1,2],[2,3]) isa Line{SVector{2,Int}}
+        @test Line((1,2),(2,3)) isa Line{SVector{2,Int}}
+        @test Line(@SVector[1,2],[2,3]) isa Line{SVector{2,Int}}
+        @test Line(@SVector[1,2],@SVector[2,3]) isa Line{SVector{2,Int}}
+
+        @test Line([1,2],[2.,3]) isa Line{SVector{2,Float64}}
+        @test Line(@SVector[1,2.],@SVector[2,3]) isa Line{SVector{2,Float64}}
+        @test Line((1,2.),(2,3)) isa Line{SVector{2,Float64}}
+    end
+
+    @testset "Evaluation" begin
+        l = Line([1,2],[2,3])
+
+        @test l(0) == [1,2]
+        @test l(1) == [1,2] + [2,3]
+        @test l(1/2) == [1,2] + [2,3]/2
     end
 end