Skip to content

Commit 0696708

Browse files
committed
add tests
1 parent 01f73b4 commit 0696708

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/basic_indexing.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,24 @@ mulX .= sqrt.(abs.(testva .* testvb))
232232
a = ArrayPartition(1:5, 1:6)
233233
a[1:8]
234234
a[[1, 3, 8]]
235+
236+
####################################################################
237+
# test when VectorOfArray is constructed from a linearly indexed
238+
# multidimensional array of arrays
239+
####################################################################
240+
241+
u_matrix = VectorOfArray(fill([1, 2], 2, 3))
242+
u_vector = VectorOfArray(vec(u_matrix.u))
243+
244+
# test broadcasting
245+
function foo!(u)
246+
@. u += 2 * u * abs(u)
247+
return u
248+
end
249+
foo!(u_matrix)
250+
foo!(u_vector)
251+
@test u_matrix u_vector
252+
253+
# test efficiency
254+
num_allocs = @allocations foo!(u_matrix)
255+
@test num_allocs == 0

0 commit comments

Comments
 (0)