Mercurial > repos > public > sbplib_julia
comparison test/Grids/zero_dim_grid_test.jl @ 2057:8a2a0d678d6f feature/lazy_tensors/pretty_printing
Merge default
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Tue, 10 Feb 2026 22:41:19 +0100 |
| parents | 471a948cd2b2 |
| children |
comparison
equal
deleted
inserted
replaced
| 1110:c0bff9f6e0fb | 2057:8a2a0d678d6f |
|---|---|
| 1 using Test | |
| 2 using Diffinitive.Grids | |
| 3 using StaticArrays | |
| 4 | |
| 5 @testset "ZeroDimGrid" begin | |
| 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 | |
| 26 | |
| 27 @testset "refine" begin | |
| 28 @test refine(ZeroDimGrid(@SVector[1.0,2.0]),1) == ZeroDimGrid(@SVector[1.0,2.0]) | |
| 29 @test refine(ZeroDimGrid(@SVector[1.0,2.0]),2) == ZeroDimGrid(@SVector[1.0,2.0]) | |
| 30 end | |
| 31 | |
| 32 @testset "coarsen" begin | |
| 33 @test coarsen(ZeroDimGrid(@SVector[1.0,2.0]),1) == ZeroDimGrid(@SVector[1.0,2.0]) | |
| 34 @test coarsen(ZeroDimGrid(@SVector[1.0,2.0]),2) == ZeroDimGrid(@SVector[1.0,2.0]) | |
| 35 end | |
| 36 | |
| 37 @testset "boundary_identifiers" begin | |
| 38 @test boundary_identifiers(ZeroDimGrid(@SVector[1.0,2.0])) == () | |
| 39 end | |
| 40 | |
| 41 @testset "boundary_grid" begin | |
| 42 @test_throws ArgumentError("ZeroDimGrid has no boundaries") boundary_grid(ZeroDimGrid(@SVector[1.0,2.0]), :bid) | |
| 43 end | |
| 44 | |
| 45 @testset "boundary_indices" begin | |
| 46 @test_throws ArgumentError("ZeroDimGrid has no boundaries") boundary_indices(ZeroDimGrid(@SVector[1.0,2.0]), :bid) | |
| 47 end | |
| 48 end |
