Mercurial > repos > public > sbplib_julia
diff test/Grids/grid_test.jl @ 1526:4df668d00d03 feature/grids/curvilinear
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 09 Apr 2024 07:58:27 +0200 |
parents | 0cd6cf62af93 |
children | 43aaf710463e |
line wrap: on
line diff
--- a/test/Grids/grid_test.jl Fri Feb 16 15:28:19 2024 +0100 +++ b/test/Grids/grid_test.jl Tue Apr 09 07:58:27 2024 +0200 @@ -15,19 +15,21 @@ @test coordinate_size(DummyGrid{SVector{3,Float64}, 2}()) == 3 @test coordinate_size(DummyGrid{SVector{3,Float64}, 2}) == 3 +end - @testset "component_type" begin - @test component_type(DummyGrid{Int,1}()) == Int - @test component_type(DummyGrid{Float64,1}()) == Float64 - @test component_type(DummyGrid{Rational,1}()) == Rational +@testset "component_type" begin + @test component_type(DummyGrid{Int,1}()) == Int + @test component_type(DummyGrid{Float64,1}()) == Float64 + @test component_type(DummyGrid{Rational,1}()) == Rational - @test component_type(DummyGrid{SVector{3,Int},2}()) == Int - @test component_type(DummyGrid{SVector{2,Float64},3}()) == Float64 - @test component_type(DummyGrid{SVector{4,Rational},4}()) == Rational + @test component_type(DummyGrid{SVector{3,Int},2}()) == Int + @test component_type(DummyGrid{SVector{2,Float64},3}()) == Float64 + @test component_type(DummyGrid{SVector{4,Rational},4}()) == Rational - @test component_type(DummyGrid{Float64,1}) == Float64 - @test component_type(DummyGrid{SVector{2,Float64},3}) == Float64 - end + @test component_type(DummyGrid{Float64,1}) == Float64 + @test component_type(DummyGrid{SVector{2,Float64},3}) == Float64 + + @test component_type(fill(@SVector[1,2], 4,2)) == Int end @testset "eval_on" begin @@ -66,33 +68,52 @@ @testset "componentview" begin v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test componentview(v, 1, 1) == [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test componentview(v, 1, 2) == [3 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test componentview(v, 2, 1) == [2 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - - @test componentview(v, 1, :) == [@SVector[1,3] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test componentview(v, 2, :) == [@SVector[2,4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test componentview(v, :, 1) == [@SVector[1,2] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test componentview(v, :, 2) == [@SVector[3,4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - + @test componentview(v, 1, 1) isa AbstractArray + @test componentview(v, 1, :) isa AbstractArray A = @SMatrix[ - 1 4 7; - 2 5 8; - 3 6 9; - ] + 1 4 7; + 2 5 8; + 3 6 9; + ] v = [A .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test componentview(v, 1:2, 1:2) == [@SMatrix[1 4;2 5] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test componentview(v, 2:3, 1:2) == [@SMatrix[2 5;3 6] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test componentview(v, 2:3, 1:2) isa AbstractArray + + # Correctness of the result is tested in ArrayComponentView end @testset "ArrayComponentView" begin v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test ArrayComponentView(v, (1,1)) == ArrayComponentView(v, (1,1)) - @test ArrayComponentView(v, (1,1)) == ArrayComponentView(copy(v), (1,1)) - @test ArrayComponentView(v, (1,1)) == [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] - @test [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] == ArrayComponentView(v, (1,1)) + @testset "==" begin + @test ArrayComponentView(v, (1,1)) == ArrayComponentView(v, (1,1)) + @test ArrayComponentView(v, (1,1)) == ArrayComponentView(copy(v), (1,1)) + @test ArrayComponentView(v, (1,1)) == [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] == ArrayComponentView(v, (1,1)) + end + + @testset "components" begin + v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + + @test ArrayComponentView(v, (1, 1)) == [1 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test ArrayComponentView(v, (1, 2)) == [3 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test ArrayComponentView(v, (2, 1)) == [2 .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + + @test ArrayComponentView(v, (1, :)) == [@SVector[1,3] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test ArrayComponentView(v, (2, :)) == [@SVector[2,4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test ArrayComponentView(v, (:, 1)) == [@SVector[1,2] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test ArrayComponentView(v, (:, 2)) == [@SVector[3,4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + + + A = @SMatrix[ + 1 4 7; + 2 5 8; + 3 6 9; + ] + v = [A .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test ArrayComponentView(v, (1:2, 1:2)) == [@SMatrix[1 4;2 5] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + @test ArrayComponentView(v, (2:3, 1:2)) == [@SMatrix[2 5;3 6] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] + end end @testset "_ncomponents" begin