aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamian Tarnawski <gthetarnav@gmail.com>2025-08-23 14:28:25 +0200
committerDamian Tarnawski <gthetarnav@gmail.com>2025-08-23 14:28:25 +0200
commit18a2980d26602028977da151a0af1a43097b7830 (patch)
treea208d0df99daf4bffd4f3965cbb8fa0702786318 /tests
parent2b6ed996be472d282fbe8cc74ee1f62f035cabac (diff)
Zero existing memory when using resize_soa (fixes #5614)
Diffstat (limited to 'tests')
-rw-r--r--tests/core/runtime/test_core_runtime.odin34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/core/runtime/test_core_runtime.odin b/tests/core/runtime/test_core_runtime.odin
index 65312a523..e6201d8f2 100644
--- a/tests/core/runtime/test_core_runtime.odin
+++ b/tests/core/runtime/test_core_runtime.odin
@@ -180,6 +180,40 @@ test_map_get :: proc(t: ^testing.T) {
}
@(test)
+test_soa_array_resize :: proc(t: ^testing.T) {
+
+ V :: struct {x: int, y: u8}
+
+ array := make(#soa[dynamic]V, 0, 2)
+ defer delete(array)
+
+ append(&array, V{1, 2}, V{3, 4})
+
+ testing.expect_value(t, len(array), 2)
+ testing.expect_value(t, array[0], V{1, 2})
+ testing.expect_value(t, array[1], V{3, 4})
+
+ resize(&array, 1)
+
+ testing.expect_value(t, len(array), 1)
+ testing.expect_value(t, array[0], V{1, 2})
+
+ resize(&array, 2)
+
+ testing.expect_value(t, len(array), 2)
+ testing.expect_value(t, array[0], V{1, 2})
+ testing.expect_value(t, array[1], V{0, 0})
+
+ resize(&array, 0)
+ resize(&array, 3)
+
+ testing.expect_value(t, len(array), 3)
+ testing.expect_value(t, array[0], V{0, 0})
+ testing.expect_value(t, array[1], V{0, 0})
+ testing.expect_value(t, array[2], V{0, 0})
+}
+
+@(test)
test_memory_equal :: proc(t: ^testing.T) {
data: [256]u8
cmp: [256]u8