Skip to content

Commit 5ddceee

Browse files
Add test for zero(VectorOfArray) preserving StructArray container type
Verifies that the rewrap-based fix correctly returns a VectorOfArray whose .u field is still a StructArray (not a plain Vector) and that all values are zeroed. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 273a065 commit 5ddceee

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/copy_static_array_test.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,13 @@ x_immutablefv = [ImmutableFV(1.0, 2.0)]
131131
for vec in [x_staticvector, x_structarray, x_mutablefv, x_immutablefv]
132132
@test typeof(similar(VectorOfArray(vec))) === typeof(VectorOfArray(vec))
133133
end
134+
135+
# Test that zero(VectorOfArray) preserves StructArray container type (via rewrap)
136+
let
137+
sa = StructArray{SVector{2, Float64}}((Float64[1.0, 2.0], Float64[3.0, 4.0]))
138+
voa = VectorOfArray(sa)
139+
z = zero(voa)
140+
@test z.u isa StructArray
141+
@test all(iszero, z.u[1])
142+
@test all(iszero, z.u[2])
143+
end

0 commit comments

Comments
 (0)