aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamian Tarnawski <gthetarnav@gmail.com>2025-09-15 14:50:33 +0200
committerDamian Tarnawski <gthetarnav@gmail.com>2025-09-15 14:50:33 +0200
commit2c3d5fe456294e2d9e9b56883b4ba44586d0baa9 (patch)
tree9b1ad782f28294d553a2e796109324fbb552d6d5
parent3d66625de0b3fe9cceb187b4c7ff8bb767d7babc (diff)
Add small array resize tests
-rw-r--r--tests/core/container/test_core_small_array.odin22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/core/container/test_core_small_array.odin b/tests/core/container/test_core_small_array.odin
index 21f35f112..86342c6a5 100644
--- a/tests/core/container/test_core_small_array.odin
+++ b/tests/core/container/test_core_small_array.odin
@@ -54,6 +54,28 @@ test_small_array_push_back_elems :: proc(t: ^testing.T) {
testing.expect(t, slice_equal(small_array.slice(&array), []int { 1, 2 }))
}
+@(test)
+test_small_array_resize :: proc(t: ^testing.T) {
+
+ array: small_array.Small_Array(4, int)
+
+ for i in 0..<4 {
+ small_array.append(&array, i+1)
+ }
+ testing.expect(t, slice_equal(small_array.slice(&array), []int{1, 2, 3, 4}), "Expected to initialize the array with 1, 2, 3, 4")
+
+ small_array.clear(&array)
+ testing.expect(t, slice_equal(small_array.slice(&array), []int{}), "Expected to clear the array")
+
+ small_array.non_zero_resize(&array, 4)
+ testing.expect(t, slice_equal(small_array.slice(&array), []int{1, 2, 3, 4}), "Expected non_zero_resize to set length 4 with previous values")
+
+ small_array.clear(&array)
+ small_array.resize(&array, 4)
+ testing.expect(t, slice_equal(small_array.slice(&array), []int{0, 0, 0, 0}), "Expected resize to set length 4 with zeroed values")
+}
+
+
slice_equal :: proc(a, b: []int) -> bool {
if len(a) != len(b) {
return false