tests/test_list.c

changeset 999
84fc42b04d3b
parent 998
bb196054f3fd
child 1022
2911c1f4a570
equal deleted inserted replaced
998:bb196054f3fd 999:84fc42b04d3b
136 ); 136 );
137 CX_TEST_ASSERT(result != 0); 137 CX_TEST_ASSERT(result != 0);
138 CX_TEST_ASSERT(errno == EINVAL); 138 CX_TEST_ASSERT(errno == EINVAL);
139 CX_TEST_ASSERT(arr_size == 0); 139 CX_TEST_ASSERT(arr_size == 0);
140 CX_TEST_ASSERT(arr_capacity == 16); 140 CX_TEST_ASSERT(arr_capacity == 16);
141 }
142 free(arr);
143 }
144
145 CX_TEST(test_array_reserve) {
146 CX_ARRAY_DECLARE_SIZED(int, arr, uint16_t);
147 cx_array_initialize(arr, 16);
148 arr_size = 5;
149 int result;
150 CX_TEST_DO {
151 result = cx_array_simple_reserve(arr, 3);
152 CX_TEST_ASSERT(result == 0);
153 CX_TEST_ASSERT(arr_size == 5);
154 CX_TEST_ASSERT(arr_capacity == 16);
155
156 result = cx_array_simple_reserve(arr, 20);
157 CX_TEST_ASSERT(result == 0);
158 CX_TEST_ASSERT(arr_size == 5);
159 CX_TEST_ASSERT(arr_capacity >= 25);
141 } 160 }
142 free(arr); 161 free(arr);
143 } 162 }
144 163
145 CX_TEST(test_array_insert_sorted) { 164 CX_TEST(test_array_insert_sorted) {
1877 CxTestSuite *suite = cx_test_suite_new("array_list"); 1896 CxTestSuite *suite = cx_test_suite_new("array_list");
1878 1897
1879 cx_test_register(suite, test_array_add); 1898 cx_test_register(suite, test_array_add);
1880 cx_test_register(suite, test_array_add8); 1899 cx_test_register(suite, test_array_add8);
1881 cx_test_register(suite, test_array_copy_unsupported_width); 1900 cx_test_register(suite, test_array_copy_unsupported_width);
1901 cx_test_register(suite, test_array_reserve);
1882 cx_test_register(suite, test_array_insert_sorted); 1902 cx_test_register(suite, test_array_insert_sorted);
1883 cx_test_register(suite, test_array_binary_search); 1903 cx_test_register(suite, test_array_binary_search);
1884 1904
1885 cx_test_register(suite, test_list_arl_create); 1905 cx_test_register(suite, test_list_arl_create);
1886 cx_test_register(suite, test_list_arl_create_simple); 1906 cx_test_register(suite, test_list_arl_create_simple);

mercurial