--- a/tests/test_list.c Mon Dec 02 20:58:17 2024 +0100 +++ b/tests/test_list.c Thu Dec 05 01:51:47 2024 +0100 @@ -142,6 +142,25 @@ free(arr); } +CX_TEST(test_array_reserve) { + CX_ARRAY_DECLARE_SIZED(int, arr, uint16_t); + cx_array_initialize(arr, 16); + arr_size = 5; + int result; + CX_TEST_DO { + result = cx_array_simple_reserve(arr, 3); + CX_TEST_ASSERT(result == 0); + CX_TEST_ASSERT(arr_size == 5); + CX_TEST_ASSERT(arr_capacity == 16); + + result = cx_array_simple_reserve(arr, 20); + CX_TEST_ASSERT(result == 0); + CX_TEST_ASSERT(arr_size == 5); + CX_TEST_ASSERT(arr_capacity >= 25); + } + free(arr); +} + CX_TEST(test_array_insert_sorted) { int d1 = 50; int d2 = 80; @@ -1879,6 +1898,7 @@ cx_test_register(suite, test_array_add); cx_test_register(suite, test_array_add8); cx_test_register(suite, test_array_copy_unsupported_width); + cx_test_register(suite, test_array_reserve); cx_test_register(suite, test_array_insert_sorted); cx_test_register(suite, test_array_binary_search);