comparison test/Grids/grid_test.jl @ 2046:3edcf447298d bugfix/component_view_missing_tests

Add missing tests for ArrayComponentView
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 05 Feb 2026 23:04:21 +0100
parents 471a948cd2b2
children
comparison
equal deleted inserted replaced
2044:b3268d0bd5bc 2046:3edcf447298d
112 ] 112 ]
113 v = [A .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] 113 v = [A .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
114 @test ArrayComponentView(v, (1:2, 1:2)) == [@SMatrix[1 4;2 5] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] 114 @test ArrayComponentView(v, (1:2, 1:2)) == [@SMatrix[1 4;2 5] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
115 @test ArrayComponentView(v, (2:3, 1:2)) == [@SMatrix[2 5;3 6] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4] 115 @test ArrayComponentView(v, (2:3, 1:2)) == [@SMatrix[2 5;3 6] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
116 end 116 end
117
118 @testset "size" begin
119 v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
120 cv = ArrayComponentView(v, (1, 1))
121
122 @test size(cv) == (3,4)
123 end
124
125 @testset "IndexStyle" begin
126 v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
127 cv = ArrayComponentView(v, (1, 1))
128
129 @test IndexStyle(cv) == IndexStyle(v)
130 end
131
132 @testset "_array_type" begin
133 v = [@SMatrix[1 3; 2 4] .+ 100*i .+ 10*j for i ∈ 1:3, j∈ 1:4]
134 cv = ArrayComponentView(v, (1, 1))
135
136 @test Grids._array_type(cv) == typeof(v)
137 end
117 end 138 end
118 139
119 @testset "_ncomponents" begin 140 @testset "_ncomponents" begin
120 @test Grids._ncomponents(Int) == 1 141 @test Grids._ncomponents(Int) == 1
121 @test Grids._ncomponents(Float64) == 1 142 @test Grids._ncomponents(Float64) == 1