Mercurial > repos > public > sbplib_julia
diff test/Grids/zero_dim_grid_test.jl @ 1260:8b9a77d2dc91 refactor/grids
Add tests and make them pass for ZeroDimGrid
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 23 Feb 2023 12:22:18 +0100 |
parents | 6323d2fe3b4f |
children | b0819f6b9d4a |
line wrap: on
line diff
--- a/test/Grids/zero_dim_grid_test.jl Thu Feb 23 12:22:00 2023 +0100 +++ b/test/Grids/zero_dim_grid_test.jl Thu Feb 23 12:22:18 2023 +0100 @@ -1,6 +1,26 @@ +using Test using Sbplib.Grids -using Test +using StaticArrays @testset "ZeroDimGrid" begin - @test_broken false + @test ZeroDimGrid(1) isa ZeroDimGrid{Int} + @test ZeroDimGrid([1,2,3]) isa ZeroDimGrid{Vector{Int}} + @test ZeroDimGrid(@SVector[1.0,2.0]) isa ZeroDimGrid{SVector{2,Float64}} + + @testset "Indexing Interface" begin + g = ZeroDimGrid(@SVector[1,2]) + + @test g[] == [1,2] + @test eachindex(g) == CartesianIndices(()) + end + + @testset "Iterator interface" begin + g = ZeroDimGrid(@SVector[1,2]) + + @test Base.IteratorSize(g) == Base.HasShape{0}() + @test eltype(g) == SVector{2,Int} + @test length(g) == 1 + @test size(g) == () + @test collect(g) == fill(@SVector[1,2]) + end end