Mercurial > repos > public > sbplib_julia
comparison 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 |
comparison
equal
deleted
inserted
replaced
1259:ee57bdb366e4 | 1260:8b9a77d2dc91 |
---|---|
1 using Test | |
1 using Sbplib.Grids | 2 using Sbplib.Grids |
2 using Test | 3 using StaticArrays |
3 | 4 |
4 @testset "ZeroDimGrid" begin | 5 @testset "ZeroDimGrid" begin |
5 @test_broken false | 6 @test ZeroDimGrid(1) isa ZeroDimGrid{Int} |
7 @test ZeroDimGrid([1,2,3]) isa ZeroDimGrid{Vector{Int}} | |
8 @test ZeroDimGrid(@SVector[1.0,2.0]) isa ZeroDimGrid{SVector{2,Float64}} | |
9 | |
10 @testset "Indexing Interface" begin | |
11 g = ZeroDimGrid(@SVector[1,2]) | |
12 | |
13 @test g[] == [1,2] | |
14 @test eachindex(g) == CartesianIndices(()) | |
15 end | |
16 | |
17 @testset "Iterator interface" begin | |
18 g = ZeroDimGrid(@SVector[1,2]) | |
19 | |
20 @test Base.IteratorSize(g) == Base.HasShape{0}() | |
21 @test eltype(g) == SVector{2,Int} | |
22 @test length(g) == 1 | |
23 @test size(g) == () | |
24 @test collect(g) == fill(@SVector[1,2]) | |
25 end | |
6 end | 26 end |