diff test/Grids/EquidistantGrid_test.jl @ 1090:9b40aeac4269 refactor/grids

Add getindex for grid
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 26 Apr 2022 14:28:42 +0200
parents e81b89ae17c4
children c4ea28d904f5
line wrap: on
line diff
--- a/test/Grids/EquidistantGrid_test.jl	Fri Apr 08 19:36:22 2022 +0200
+++ b/test/Grids/EquidistantGrid_test.jl	Tue Apr 26 14:28:42 2022 +0200
@@ -43,6 +43,17 @@
         @test [gp[i]...] ≈ [p[i]...] atol=5e-13
     end
 
+
+    @testset "getindex" begin
+        g = EquidistantGrid((5,3), (-1.0,0.0), (0.0,7.11))
+        @test g[1,1] == (-1.0,0.0)
+        @test g[1,3] == (-1.0,7.11)
+        @test g[5,1] == (0.0,0.0)
+        @test g[5,3] == (0.0,7.11)
+
+        @test g[4,2] == (-0.25,7.11/2)
+    end
+
     # restrict
     g = EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))
     @test restrict(g, 1) == EquidistantGrid(5,0.0,2.0)