Skip to content

Commit 5b42c36

Browse files
kshyattandyferris
authored andcommitted
More tests for StaticArrays as indices (#205)
1 parent 0dfe807 commit 5b42c36

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/indexing.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@
119119
@test (ma[1,2,1,1] = 36; ma[1,2,1,1] === 36)
120120
@test (ma[2,1,1,1] = 48; ma[2,1,1,1] === 48)
121121
end
122+
123+
@testset "4D StaticArray indexing" begin
124+
sa = SArray{Tuple{2,2,2,2}, Int}([i*j*k*l for i = 1:2, j = 2:3, k=3:4, l=4:5])
125+
@test (@inferred getindex(sa, 1, 1, 1, SVector(1,2))) === @SVector [24,30]
126+
@test (@inferred getindex(sa, 1, 1, SVector(1,2), 1)) === @SVector [24,32]
127+
@test (@inferred getindex(sa, 1, SVector(1,2), 1, 1)) === @SVector [24,36]
128+
@test (@inferred getindex(sa, SVector(1,2), 1, 1, 1)) === @SVector [24,48]
129+
a = [i*j*k*l for i = 1:2, j = 2:3, k=3:4, l=4:5]
130+
@test (@inferred getindex(a, 1, 1, 1, SVector(1,2))) == [24,30]
131+
@test (@inferred getindex(a, 1, 1, SVector(1,2), 1)) == [24,32]
132+
@test (@inferred getindex(a, 1, SVector(1,2), 1, 1)) == [24,36]
133+
@test (@inferred getindex(a, SVector(1,2), 1, 1, 1)) == [24,48]
134+
end
122135

123136
@testset "Indexing with empty vectors" begin
124137
a = randn(2,2)

0 commit comments

Comments
 (0)