changeset 1125:b9c6b0d8f0fa feature/grids

Add testsets to existing tests
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 05 Oct 2022 21:24:13 +0200
parents aeeffca46b94
children 832ac87a54a3
files test/Grids/equidistant_grid_test.jl
diffstat 1 files changed, 33 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/test/Grids/equidistant_grid_test.jl	Fri Jul 15 09:56:25 2022 +0200
+++ b/test/Grids/equidistant_grid_test.jl	Wed Oct 05 21:24:13 2022 +0200
@@ -23,39 +23,43 @@
     @test dim(EquidistantGrid(4,0.0,1.0)) == 1
     @test dim(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == 2
 
-    # spacing
-    @test [spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(1. /3,)...] atol=5e-13
-    @test [spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(0.5, 1.)...] atol=5e-13
-
-    # inverse_spacing
-    @test [inverse_spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(3.,)...] atol=5e-13
-    @test [inverse_spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(2, 1.)...] atol=5e-13
+    @testset "spacing" begin
+        @test [spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(1. /3,)...] atol=5e-13
+        @test [spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(0.5, 1.)...] atol=5e-13
+    end
 
-    # points
-    g = EquidistantGrid((5,3), (-1.0,0.0), (0.0,7.11))
-    gp = points(g);
-    p = [(-1.,0.)      (-1.,7.11/2)   (-1.,7.11);
-         (-0.75,0.)    (-0.75,7.11/2) (-0.75,7.11);
-         (-0.5,0.)     (-0.5,7.11/2)  (-0.5,7.11);
-         (-0.25,0.)    (-0.25,7.11/2) (-0.25,7.11);
-         (0.,0.)       (0.,7.11/2)    (0.,7.11)]
-    for i ∈ eachindex(gp)
-        @test [gp[i]...] ≈ [p[i]...] atol=5e-13
+    @testset "inverse_spacing" begin
+        @test [inverse_spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(3.,)...] atol=5e-13
+        @test [inverse_spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(2, 1.)...] atol=5e-13
     end
 
-    # restrict
-    g = EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))
-    @test restrict(g, 1) == EquidistantGrid(5,0.0,2.0)
-    @test restrict(g, 2) == EquidistantGrid(3,0.0,1.0)
+    @testset "points" begin
+        g = EquidistantGrid((5,3), (-1.0,0.0), (0.0,7.11))
+        gp = points(g);
+        p = [(-1.,0.)      (-1.,7.11/2)   (-1.,7.11);
+            (-0.75,0.)    (-0.75,7.11/2) (-0.75,7.11);
+            (-0.5,0.)     (-0.5,7.11/2)  (-0.5,7.11);
+            (-0.25,0.)    (-0.25,7.11/2) (-0.25,7.11);
+            (0.,0.)       (0.,7.11/2)    (0.,7.11)]
+        for i ∈ eachindex(gp)
+            @test [gp[i]...] ≈ [p[i]...] atol=5e-13
+        end
+    end
 
-    g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0))
-    @test restrict(g, 1) == EquidistantGrid(2,0.0,2.0)
-    @test restrict(g, 2) == EquidistantGrid(5,0.0,1.0)
-    @test restrict(g, 3) == EquidistantGrid(3,0.0,3.0)
-    @test restrict(g, 1:2) == EquidistantGrid((2,5),(0.0,0.0),(2.0,1.0))
-    @test restrict(g, 2:3) == EquidistantGrid((5,3),(0.0,0.0),(1.0,3.0))
-    @test restrict(g, [1,3]) == EquidistantGrid((2,3),(0.0,0.0),(2.0,3.0))
-    @test restrict(g, [2,1]) == EquidistantGrid((5,2),(0.0,0.0),(1.0,2.0))
+    @testset "restrict" begin
+        g = EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))
+        @test restrict(g, 1) == EquidistantGrid(5,0.0,2.0)
+        @test restrict(g, 2) == EquidistantGrid(3,0.0,1.0)
+
+        g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0))
+        @test restrict(g, 1) == EquidistantGrid(2,0.0,2.0)
+        @test restrict(g, 2) == EquidistantGrid(5,0.0,1.0)
+        @test restrict(g, 3) == EquidistantGrid(3,0.0,3.0)
+        @test restrict(g, 1:2) == EquidistantGrid((2,5),(0.0,0.0),(2.0,1.0))
+        @test restrict(g, 2:3) == EquidistantGrid((5,3),(0.0,0.0),(1.0,3.0))
+        @test restrict(g, [1,3]) == EquidistantGrid((2,3),(0.0,0.0),(2.0,3.0))
+        @test restrict(g, [2,1]) == EquidistantGrid((5,2),(0.0,0.0),(1.0,2.0))
+    end
 
     @testset "boundary_identifiers" begin
         g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0))