Mercurial > repos > public > sbplib_julia
annotate 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 |
rev | line source |
---|---|
1260
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
1 using Test |
1245 | 2 using Sbplib.Grids |
1260
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
3 using StaticArrays |
1245 | 4 |
5 @testset "ZeroDimGrid" begin | |
1260
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
6 @test ZeroDimGrid(1) isa ZeroDimGrid{Int} |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
7 @test ZeroDimGrid([1,2,3]) isa ZeroDimGrid{Vector{Int}} |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
8 @test ZeroDimGrid(@SVector[1.0,2.0]) isa ZeroDimGrid{SVector{2,Float64}} |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
9 |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
10 @testset "Indexing Interface" begin |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
11 g = ZeroDimGrid(@SVector[1,2]) |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
12 |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
13 @test g[] == [1,2] |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
14 @test eachindex(g) == CartesianIndices(()) |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
15 end |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
16 |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
17 @testset "Iterator interface" begin |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
18 g = ZeroDimGrid(@SVector[1,2]) |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
19 |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
20 @test Base.IteratorSize(g) == Base.HasShape{0}() |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
21 @test eltype(g) == SVector{2,Int} |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
22 @test length(g) == 1 |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
23 @test size(g) == () |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
24 @test collect(g) == fill(@SVector[1,2]) |
8b9a77d2dc91
Add tests and make them pass for ZeroDimGrid
Jonatan Werpers <jonatan@werpers.com>
parents:
1245
diff
changeset
|
25 end |
1245 | 26 end |