Skip to content

Commit 9cefca4

Browse files
committed
Test nested OffsetArray construction
3/4 tests pass
1 parent e7bc016 commit 9cefca4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/runtests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ end
124124
@test axes(y) == (r,)
125125
end
126126

127+
@testset "OffsetArray of OffsetArray construction" begin
128+
# guarantee no unnecessary nesting of `OffsetArray`s
129+
r = -2:5
130+
d = collect(r)
131+
y = OffsetArray(d, r)
132+
133+
# range constructor
134+
y0 = OffsetArray(y, 0:7)
135+
@test y0[0] == r[1]
136+
@test typeof(parent(y0)) <: Array
137+
138+
# offset constructor
139+
y1 = OffsetArray(y, +2)
140+
@test y1[0] == r[1]
141+
@test typeof(parent(y1)) <: Array
142+
end
143+
127144
@testset "Axes supplied to constructor correspond to final result" begin
128145
# Ref https://github.com/JuliaArrays/OffsetArrays.jl/pull/65#issuecomment-457181268
129146
B = BidirectionalVector([1, 2, 3], -2)

0 commit comments

Comments
 (0)