diff test/Grids/tensor_grid_test.jl @ 1848:a4c9966f7d34

Merge feature/grids/tensor_grid/spacing
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 10 Jan 2025 20:22:04 +0100
parents 054447ac4b0e
children 516eaabf1169
line wrap: on
line diff
--- a/test/Grids/tensor_grid_test.jl	Thu Jan 09 12:28:06 2025 +0100
+++ b/test/Grids/tensor_grid_test.jl	Fri Jan 10 20:22:04 2025 +0100
@@ -137,6 +137,27 @@
         @test axes(g) == (1:11,1:6)
     end
 
+    @testset "spacing" begin
+        g₁ = EquidistantGrid(range(0,1,length=11))
+        g₂ = EquidistantGrid(range(2,3,length=6))
+        g₃ = ZeroDimGrid(@SVector[1,2])
+
+        @test spacing(TensorGrid(g₁)) == (1/10,)
+        @test spacing(TensorGrid(g₂)) == (1/5,)
+
+        @test spacing(TensorGrid(g₁, g₂)) == (1/10, 1/5)
+
+        @test spacing(TensorGrid(g₁, g₃)) == (1/10,)
+        @test spacing(TensorGrid(g₃, g₂)) == (1/5,)
+
+
+        @test spacing(TensorGrid(g₁, g₂, g₁)) == (1/10, 1/5, 1/10)
+
+        @test spacing(TensorGrid(g₃, g₂, g₁)) == (1/5, 1/10)
+        @test spacing(TensorGrid(g₁, g₃, g₁)) == (1/10, 1/10)
+        @test spacing(TensorGrid(g₁, g₂, g₃)) == (1/10, 1/5)
+    end
+
     @testset "min_spacing" begin
         g₁ = EquidistantGrid(range(0,1,length=11))
         g₂ = EquidistantGrid(range(2,3,length=6))