192 UCX_TEST_END |
196 UCX_TEST_END |
193 fclose(f); |
197 fclose(f); |
194 |
198 |
195 unlink("test_ucx_map_store"); |
199 unlink("test_ucx_map_store"); |
196 } |
200 } |
|
201 |
|
202 UCX_TEST_IMPLEMENT(test_ucx_map_clone) { |
|
203 UcxMap *map = ucx_map_new(4); |
|
204 |
|
205 ucx_map_cstr_put(map, "key1", "value1"); |
|
206 ucx_map_cstr_put(map, "key2", "value2"); |
|
207 ucx_map_cstr_put(map, "key3", "value3"); |
|
208 |
|
209 UcxMap *clone = ucx_map_clone(map, NULL, NULL); |
|
210 |
|
211 char *v1 = ucx_map_cstr_get(map, "key1"); |
|
212 char *v2 = ucx_map_cstr_get(map, "key2"); |
|
213 char *v3 = ucx_map_cstr_get(map, "key3"); |
|
214 |
|
215 UCX_TEST_BEGIN |
|
216 |
|
217 UCX_TEST_ASSERT(v1 != NULL, "failed key 1"); |
|
218 UCX_TEST_ASSERT(v2 != NULL, "failed key 2"); |
|
219 UCX_TEST_ASSERT(v3 != NULL, "failed key 3"); |
|
220 |
|
221 char *c1 = ucx_map_cstr_get(clone, "key1"); |
|
222 char *c2 = ucx_map_cstr_get(clone, "key2"); |
|
223 char *c3 = ucx_map_cstr_get(clone, "key3"); |
|
224 |
|
225 UCX_TEST_ASSERT(c1 != NULL, "failed key 1 (clone)"); |
|
226 UCX_TEST_ASSERT(c2 != NULL, "failed key 2 (clone)"); |
|
227 UCX_TEST_ASSERT(c3 != NULL, "failed key 3 (clone)"); |
|
228 |
|
229 UCX_TEST_ASSERT(strcmp(c1, v1) == 0, "value error for key1"); |
|
230 UCX_TEST_ASSERT(strcmp(c2, v2) == 0, "value error for key2"); |
|
231 UCX_TEST_ASSERT(strcmp(c3, v3) == 0, "value error for key3"); |
|
232 |
|
233 UCX_TEST_END |
|
234 |
|
235 ucx_map_free(map); |
|
236 ucx_map_free(clone); |
|
237 } |