diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-26 14:16:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-26 14:16:54 +0100 |
| commit | 51f79724ed25252088211f1128f1987499bb91f4 (patch) | |
| tree | 63cb22a1e1a0eb45846719572fb678d4a51a0079 /tests | |
| parent | 62a03f118ee77b94319a40bee494494d88e6fc31 (diff) | |
| parent | e163c20a02a27646ba46fc094a077bb8118d2e1e (diff) | |
Merge pull request #5686 from thetarnav/zero-small-array-resize
Zero small array resize
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/container/test_core_small_array.odin | 22 |
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 |