Skip to content

Commit 6609672

Browse files
committed
add tests
1 parent 5bf7a41 commit 6609672

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

lib/RecursiveArrayToolsRaggedArrays/test/runtests.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,4 +986,34 @@ using Test
986986
@test rd isa RecursiveArrayTools.AbstractRaggedVectorOfArray
987987
@test !(rd isa AbstractArray)
988988
end
989+
990+
@testset "recursivefill! for RaggedVectorOfArray" begin
991+
# Bool argument — the pattern used by ODE solver cache initialisation
992+
r = RaggedVectorOfArray([ones(2), ones(3)])
993+
recursivefill!(r, false)
994+
@test r[:, 1] == [0.0, 0.0]
995+
@test r[:, 2] == [0.0, 0.0, 0.0]
996+
997+
# Numeric argument
998+
r2 = RaggedVectorOfArray([zeros(2), zeros(3)])
999+
recursivefill!(r2, 1.0)
1000+
@test r2[:, 1] == [1.0, 1.0]
1001+
@test r2[:, 2] == [1.0, 1.0, 1.0]
1002+
1003+
# Ragged sizes are preserved
1004+
@test length(r[:, 1]) == 2
1005+
@test length(r[:, 2]) == 3
1006+
end
1007+
1008+
@testset "recursivecopy! for RaggedVectorOfArray" begin
1009+
src = RaggedVectorOfArray([ones(2), 2 * ones(3)])
1010+
dst = RaggedVectorOfArray([zeros(2), zeros(3)])
1011+
recursivecopy!(dst, src)
1012+
@test dst[:, 1] == [1.0, 1.0]
1013+
@test dst[:, 2] == [2.0, 2.0, 2.0]
1014+
1015+
# Verify deep copy — modifying src must not affect dst
1016+
src[:, 1] .= 99.0
1017+
@test dst[:, 1] == [1.0, 1.0]
1018+
end
9891019
end

0 commit comments

Comments
 (0)