155 CX_TEST_ASSERT(cxListSize(list) == 0); |
155 CX_TEST_ASSERT(cxListSize(list) == 0); |
156 } |
156 } |
157 cxListFree(list); |
157 cxListFree(list); |
158 } |
158 } |
159 |
159 |
|
160 CX_TEST(test_kv_list_insert_array_and_set_keys) { |
|
161 CxList *list = cxKvListCreateSimple(sizeof(int)); |
|
162 CX_TEST_DO { |
|
163 int arr[] = { 13, 21, 34, 55, 89 }; |
|
164 CX_TEST_ASSERT(5 == cxListAddArray(list, arr, 5)); |
|
165 CX_TEST_ASSERT(5 == cxListSize(list)); |
|
166 CX_TEST_ASSERT(0 == cxKvListSetKey(list, 0, "xyz")); |
|
167 CX_TEST_ASSERT(0 == cxKvListSetKey(list, 1, "abc")); |
|
168 CX_TEST_ASSERT(0 == cxKvListSetKey(list, 2, "def")); |
|
169 CX_TEST_ASSERT(0 == cxKvListSetKey(list, 3, "ghi")); |
|
170 CX_TEST_ASSERT(0 == cxKvListSetKey(list, 4, "jkl")); |
|
171 |
|
172 CxMap *map = cxKvListAsMap(list); |
|
173 CX_TEST_ASSERT(5 == cxMapSize(map)); |
|
174 CX_TEST_ASSERT(*(int*)cxMapGet(map, "xyz") == 13); |
|
175 CX_TEST_ASSERT(*(int*)cxMapGet(map, "abc") == 21); |
|
176 CX_TEST_ASSERT(*(int*)cxMapGet(map, "def") == 34); |
|
177 CX_TEST_ASSERT(*(int*)cxMapGet(map, "ghi") == 55); |
|
178 CX_TEST_ASSERT(*(int*)cxMapGet(map, "jkl") == 89); |
|
179 } |
|
180 cxListFree(list); |
|
181 } |
|
182 |
160 |
183 |
161 static int kv_list_test_destr_val; |
184 static int kv_list_test_destr_val; |
162 static void kv_list_test_destr(void *data) { |
185 static void kv_list_test_destr(void *data) { |
163 kv_list_test_destr_val = *(int*)data; |
186 kv_list_test_destr_val = *(int*)data; |
164 } |
187 } |
310 cx_test_register(suite, test_kv_list_free_as_list); |
333 cx_test_register(suite, test_kv_list_free_as_list); |
311 cx_test_register(suite, test_kv_list_map_put); |
334 cx_test_register(suite, test_kv_list_map_put); |
312 cx_test_register(suite, test_kv_list_map_put_ptr); |
335 cx_test_register(suite, test_kv_list_map_put_ptr); |
313 cx_test_register(suite, test_kv_list_map_remove); |
336 cx_test_register(suite, test_kv_list_map_remove); |
314 cx_test_register(suite, test_kv_list_set_key); |
337 cx_test_register(suite, test_kv_list_set_key); |
|
338 cx_test_register(suite, test_kv_list_insert_array_and_set_keys); |
315 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); |
339 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); |
316 cx_test_register(suite, test_kv_list_list_remove_destr_in_map); |
340 cx_test_register(suite, test_kv_list_list_remove_destr_in_map); |
317 cx_test_register(suite, test_kv_list_map_remove_destr_in_list); |
341 cx_test_register(suite, test_kv_list_map_remove_destr_in_list); |
318 cx_test_register(suite, test_kv_list_map_remove_destr_in_map); |
342 cx_test_register(suite, test_kv_list_map_remove_destr_in_map); |
319 cx_test_register(suite, test_kv_list_list_clear_destr_in_list); |
343 cx_test_register(suite, test_kv_list_list_clear_destr_in_list); |