117 CX_TEST_ASSERT(0 != cxMapRemove(map, "xyz")); |
117 CX_TEST_ASSERT(0 != cxMapRemove(map, "xyz")); |
118 } |
118 } |
119 cxListFree(list); |
119 cxListFree(list); |
120 } |
120 } |
121 |
121 |
|
122 CX_TEST(test_kv_list_set_key) { |
|
123 CxList *list = cxKvListCreateSimple(sizeof(int)); |
|
124 int x; |
|
125 CX_TEST_DO { |
|
126 x = 47; |
|
127 cxListAdd(list, &x); |
|
128 CX_TEST_ASSERT(0 == cxKvListSetKey(list, 0, "xyz")); |
|
129 |
|
130 CxMap *map = cxKvListAsMap(list); |
|
131 |
|
132 CX_TEST_ASSERT(cxMapSize(map) == 1); |
|
133 |
|
134 int *y = cxMapGet(map, "xyz"); |
|
135 CX_TEST_ASSERT(y != NULL); |
|
136 CX_TEST_ASSERT(*y == 47); |
|
137 |
|
138 CX_TEST_ASSERT(0 == cxMapRemove(map, "xyz")); |
|
139 CX_TEST_ASSERT(cxMapGet(map, "xyz") == NULL); |
|
140 |
|
141 CX_TEST_ASSERT(cxListSize(list) == 0); |
|
142 } |
|
143 cxListFree(list); |
|
144 } |
|
145 |
|
146 |
122 static int kv_list_test_destr_val; |
147 static int kv_list_test_destr_val; |
123 static void kv_list_test_destr(void *data) { |
148 static void kv_list_test_destr(void *data) { |
124 kv_list_test_destr_val = *(int*)data; |
149 kv_list_test_destr_val = *(int*)data; |
125 } |
150 } |
126 |
151 |
254 cx_test_register(suite, test_kv_list_map_as_list); |
279 cx_test_register(suite, test_kv_list_map_as_list); |
255 cx_test_register(suite, test_kv_list_free_as_map); |
280 cx_test_register(suite, test_kv_list_free_as_map); |
256 cx_test_register(suite, test_kv_list_free_as_list); |
281 cx_test_register(suite, test_kv_list_free_as_list); |
257 cx_test_register(suite, test_kv_list_map_put); |
282 cx_test_register(suite, test_kv_list_map_put); |
258 cx_test_register(suite, test_kv_list_map_remove); |
283 cx_test_register(suite, test_kv_list_map_remove); |
|
284 cx_test_register(suite, test_kv_list_set_key); |
259 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); |
285 cx_test_register(suite, test_kv_list_list_remove_destr_in_list); |
260 cx_test_register(suite, test_kv_list_list_remove_destr_in_map); |
286 cx_test_register(suite, test_kv_list_list_remove_destr_in_map); |
261 cx_test_register(suite, test_kv_list_map_remove_destr_in_list); |
287 cx_test_register(suite, test_kv_list_map_remove_destr_in_list); |
262 cx_test_register(suite, test_kv_list_map_remove_destr_in_map); |
288 cx_test_register(suite, test_kv_list_map_remove_destr_in_map); |
263 cx_test_register(suite, test_kv_list_list_clear_destr_in_list); |
289 cx_test_register(suite, test_kv_list_list_clear_destr_in_list); |