Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlchan authored and ChrisRackauckas committed Feb 21, 2024
1 parent dc597a4 commit 6ab92ed
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/basic_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,24 @@ mulX .= sqrt.(abs.(testva .* testvb))
a = ArrayPartition(1:5, 1:6)
a[1:8]
a[[1, 3, 8]]

####################################################################
# test when VectorOfArray is constructed from a linearly indexed
# multidimensional array of arrays
####################################################################

u_matrix = VectorOfArray(fill([1, 2], 2, 3))
u_vector = VectorOfArray(vec(u_matrix.u))

# test broadcasting
function foo!(u)
@. u += 2 * u * abs(u)
return u
end
foo!(u_matrix)
foo!(u_vector)
@test u_matrix u_vector

# test efficiency
num_allocs = @allocations foo!(u_matrix)
@test num_allocs == 0

0 comments on commit 6ab92ed

Please sign in to comment.