--- a/test/map_tests.c Thu Oct 04 18:23:32 2012 +0200 +++ b/test/map_tests.c Thu Oct 04 18:46:57 2012 +0200 @@ -4,6 +4,10 @@ #include "map_tests.h" +#ifndef _WIN32 +#include <unistd.h> +#endif /* not _WIN32 */ + UCX_TEST_IMPLEMENT(test_ucx_map_new) { UcxMap *map = ucx_map_new(16); UCX_TEST_BEGIN @@ -194,3 +198,40 @@ unlink("test_ucx_map_store"); } + +UCX_TEST_IMPLEMENT(test_ucx_map_clone) { + UcxMap *map = ucx_map_new(4); + + ucx_map_cstr_put(map, "key1", "value1"); + ucx_map_cstr_put(map, "key2", "value2"); + ucx_map_cstr_put(map, "key3", "value3"); + + UcxMap *clone = ucx_map_clone(map, NULL, NULL); + + char *v1 = ucx_map_cstr_get(map, "key1"); + char *v2 = ucx_map_cstr_get(map, "key2"); + char *v3 = ucx_map_cstr_get(map, "key3"); + + UCX_TEST_BEGIN + + UCX_TEST_ASSERT(v1 != NULL, "failed key 1"); + UCX_TEST_ASSERT(v2 != NULL, "failed key 2"); + UCX_TEST_ASSERT(v3 != NULL, "failed key 3"); + + char *c1 = ucx_map_cstr_get(clone, "key1"); + char *c2 = ucx_map_cstr_get(clone, "key2"); + char *c3 = ucx_map_cstr_get(clone, "key3"); + + UCX_TEST_ASSERT(c1 != NULL, "failed key 1 (clone)"); + UCX_TEST_ASSERT(c2 != NULL, "failed key 2 (clone)"); + UCX_TEST_ASSERT(c3 != NULL, "failed key 3 (clone)"); + + UCX_TEST_ASSERT(strcmp(c1, v1) == 0, "value error for key1"); + UCX_TEST_ASSERT(strcmp(c2, v2) == 0, "value error for key2"); + UCX_TEST_ASSERT(strcmp(c3, v3) == 0, "value error for key3"); + + UCX_TEST_END + + ucx_map_free(map); + ucx_map_free(clone); +}