Support using allocator resize in _reserve_soa (fixes #5615)

This commit is contained in:
Damian Tarnawski
2025-08-23 12:55:07 +02:00
parent 2b6ed996be
commit 05706864b7
2 changed files with 79 additions and 7 deletions
+26
View File
@@ -179,6 +179,32 @@ test_map_get :: proc(t: ^testing.T) {
}
}
@(test)
test_soa_array_allocator_resize :: proc(t: ^testing.T) {
arena: runtime.Arena
context.allocator = runtime.arena_allocator(&arena)
defer runtime.arena_destroy(&arena)
array, err := make(#soa[dynamic][2]int, 2, 3)
array[0] = [2]int{1, 2}
array[1] = [2]int{3, 4}
testing.expect_value(t, err, nil)
testing.expect_value(t, len(array), 2)
testing.expect_value(t, cap(array), 3)
err = resize(&array, 4)
testing.expect_value(t, err, nil)
testing.expect_value(t, len(array), 4)
testing.expect_value(t, cap(array), 4)
testing.expect_value(t, array[0], [2]int{1, 2})
testing.expect_value(t, array[1], [2]int{3, 4})
testing.expect_value(t, array[2], [2]int{0, 0})
testing.expect_value(t, array[3], [2]int{0, 0})
}
@(test)
test_memory_equal :: proc(t: ^testing.T) {
data: [256]u8