diff test/Grids/grid_test.jl @ 1474:276c38a48aac feature/grids/componentview

Start implementing componentview
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 01 Dec 2023 13:34:03 +0100
parents 86026367a9ff
children 62f9d0387a2a
line wrap: on
line diff
--- a/test/Grids/grid_test.jl	Fri Dec 01 11:48:04 2023 +0100
+++ b/test/Grids/grid_test.jl	Fri Dec 01 13:34:03 2023 +0100
@@ -63,6 +63,17 @@
     @test eval_on(g, f) == map(x̄->f(x̄...), g)
 end
 
+@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]
+
+    # should work with colon
+    # should return a view which can be index like the grid function
+end
+
 @testset "_ncomponents" begin
     @test Grids._ncomponents(Int) == 1
     @test Grids._ncomponents(Float64) == 1