Mercurial > repos > public > sbplib_julia
changeset 1348:279179677040 refactor/grids
Add testsets under "Indexing interface" for tensor grids
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 19 May 2023 14:31:16 +0200 |
parents | 08f06bfacd5c |
children | 42ecd4b3e215 |
files | test/Grids/tensor_grid_test.jl |
diffstat | 1 files changed, 21 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/test/Grids/tensor_grid_test.jl Thu May 18 22:53:31 2023 +0200 +++ b/test/Grids/tensor_grid_test.jl Fri May 19 14:31:16 2023 +0200 @@ -17,28 +17,32 @@ @test TensorGrid(g₁, g₄, g₂) isa Grid{SVector{4,Float64}, 2} @testset "Indexing Interface" begin - @test TensorGrid(g₁, g₂)[1,1] isa SVector{2,Float64} - @test TensorGrid(g₁, g₂)[1,1] == [0.0,2.0] - @test TensorGrid(g₁, g₂)[3,5] == [0.2,2.8] - @test TensorGrid(g₁, g₂)[10,6] == [0.9,3.0] + @testset "regular indexing" begin + @test TensorGrid(g₁, g₂)[1,1] isa SVector{2,Float64} + @test TensorGrid(g₁, g₂)[1,1] == [0.0,2.0] + @test TensorGrid(g₁, g₂)[3,5] == [0.2,2.8] + @test TensorGrid(g₁, g₂)[10,6] == [0.9,3.0] - @test TensorGrid(g₁, g₃)[1,1] isa SVector{2,Float64} - @test TensorGrid(g₁, g₃)[1,1] == [0.0,1.0] + @test TensorGrid(g₁, g₃)[1,1] isa SVector{2,Float64} + @test TensorGrid(g₁, g₃)[1,1] == [0.0,1.0] - @test TensorGrid(g₁, g₂, g₃)[3,4,5] isa SVector{3,Float64} - @test TensorGrid(g₁, g₂, g₃)[3,4,5] == [0.2, 2.6, 5.0] + @test TensorGrid(g₁, g₂, g₃)[3,4,5] isa SVector{3,Float64} + @test TensorGrid(g₁, g₂, g₃)[3,4,5] == [0.2, 2.6, 5.0] - @test TensorGrid(g₁, g₄)[3] isa SVector{3,Float64} - @test TensorGrid(g₁, g₄)[3] == [0.2, 1., 2.] + @test TensorGrid(g₁, g₄)[3] isa SVector{3,Float64} + @test TensorGrid(g₁, g₄)[3] == [0.2, 1., 2.] - @test TensorGrid(g₁, g₄, g₂)[3,2] isa SVector{4,Float64} - @test TensorGrid(g₁, g₄, g₂)[3,2] == [0.2, 1., 2., 2.2] + @test TensorGrid(g₁, g₄, g₂)[3,2] isa SVector{4,Float64} + @test TensorGrid(g₁, g₄, g₂)[3,2] == [0.2, 1., 2., 2.2] + end - @test eachindex(TensorGrid(g₁, g₂)) == CartesianIndices((11,6)) - @test eachindex(TensorGrid(g₁, g₃)) == CartesianIndices((11,10)) - @test eachindex(TensorGrid(g₁, g₂, g₃)) == CartesianIndices((11,6,10)) - @test eachindex(TensorGrid(g₁, g₄)) == CartesianIndices((11,)) - @test eachindex(TensorGrid(g₁, g₄, g₂)) == CartesianIndices((11,6)) + @testset "eachindex" begin + @test eachindex(TensorGrid(g₁, g₂)) == CartesianIndices((11,6)) + @test eachindex(TensorGrid(g₁, g₃)) == CartesianIndices((11,10)) + @test eachindex(TensorGrid(g₁, g₂, g₃)) == CartesianIndices((11,6,10)) + @test eachindex(TensorGrid(g₁, g₄)) == CartesianIndices((11,)) + @test eachindex(TensorGrid(g₁, g₄, g₂)) == CartesianIndices((11,6)) + end end @testset "Iterator interface" begin