test/map_tests.c

changeset 80
0125e4089f88
parent 76
655020a30e77
child 88
18823857ce79
--- a/test/map_tests.c	Wed Feb 06 14:31:44 2013 +0100
+++ b/test/map_tests.c	Wed Feb 06 14:35:15 2013 +0100
@@ -33,36 +33,38 @@
     td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000;
 
     UCX_TEST_BEGIN
-    ucx_map_cstr_put(map, "Key2", &td[2]); /* 0 */
-    ucx_map_cstr_put(map, "Key0", &td[0]); /* 0 */
-    ucx_map_cstr_put(map, "Key1", &td[1]); /* 3 */
-    ucx_map_cstr_put(map, "KeY3", &td[3]); /* 2 */
-    ucx_map_cstr_put(map, "KEY4", &td[4]); /* 0 */
+    ucx_map_cstr_put(map, "Key2", &td[2]); /* 3.2 */
+    ucx_map_cstr_put(map, "Key0", &td[0]); /* 0.0 */
+    ucx_map_cstr_put(map, "Key1", &td[1]); /* 3.0 */
+    ucx_map_cstr_put(map, "KeY3", &td[3]); /* 3.1 */
+    ucx_map_cstr_put(map, "KEY4", &td[4]); /* 1.0 */
     
     UCX_TEST_ASSERT(*((int*)map->map[0]->data) == td[0], "failed Key0");
-    UCX_TEST_ASSERT(map->map[0]->next != NULL, "no list at slot 0");
-    UCX_TEST_ASSERT(*((int*)map->map[0]->next->data) == td[2], "failed Key2");
-    UCX_TEST_ASSERT(map->map[0]->next->next != NULL, "list corrupt at slot 0");
-    UCX_TEST_ASSERT(*((int*)map->map[0]->next->next->data) == td[4],
-            "failed Key4")
-    UCX_TEST_ASSERT(map->map[0]->next->next->next == NULL,
-            "slot 0 not terminated")
-
-    UCX_TEST_ASSERT(map->map[1] == NULL, "slot 1 not terminated");
+    UCX_TEST_ASSERT(*((int*)map->map[1]->data) == td[4], "failed KEY4");
+    UCX_TEST_ASSERT(*((int*)map->map[3]->data) == td[1], "failed Key1");
+    
+    UCX_TEST_ASSERT(map->map[3]->next != NULL, "no list at slot 3");
+    UCX_TEST_ASSERT(map->map[3]->next->next != NULL, "list corrupt at slot 3");
+    UCX_TEST_ASSERT(*((int*)map->map[3]->next->data) == td[3],
+            "failed KeY3")
+    UCX_TEST_ASSERT(*((int*)map->map[3]->next->next->data) == td[2],
+            "failed KeY2");
 
-    UCX_TEST_ASSERT(*((int*)map->map[2]->data) == td[3], "failed KeY3");
-    UCX_TEST_ASSERT(map->map[2]->next == NULL, "slot 2 not terminated");
+    UCX_TEST_ASSERT(map->map[0]->next == NULL, "slot 0 not terminated");
+    UCX_TEST_ASSERT(map->map[1]->next == NULL, "slot 1 not terminated");
+    UCX_TEST_ASSERT(map->map[2] == NULL, "slot 2 not empty");
+    UCX_TEST_ASSERT(map->map[3]->next->next->next == NULL,
+            "slot 3 not terminated")
 
-    UCX_TEST_ASSERT(*((int*)map->map[3]->data) == td[1], "failed Key1");
-
-    ucx_map_cstr_put(map, "Key0", &td[3]); /* 0 */
+    ucx_map_cstr_put(map, "KeY3", &td[4]); /* replace 3.1 */
     
-    UCX_TEST_ASSERT(*((int*)map->map[0]->data) == td[3], "overwrite failed");
-    UCX_TEST_ASSERT(*((int*)map->map[0]->next->data) == td[2],
+    UCX_TEST_ASSERT(*((int*)map->map[3]->data) == td[1],
             "overwrite failed")
-    UCX_TEST_ASSERT(*((int*)map->map[0]->next->next->data) == td[4], 
+    UCX_TEST_ASSERT(*((int*)map->map[3]->next->data) == td[4],
+            "overwrite failed");
+    UCX_TEST_ASSERT(*((int*)map->map[3]->next->next->data) == td[2], 
             "overwrite failed")
-    UCX_TEST_ASSERT(map->map[0]->next->next->next == NULL, "overwrite failed");
+    UCX_TEST_ASSERT(map->map[3]->next->next->next == NULL, "overwrite failed");
     
     UCX_TEST_END
     ucx_map_free(map);
@@ -74,11 +76,11 @@
     int td[5];
     td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000;
 
-    ucx_map_cstr_put(map, "Key2", &td[2]); /* 0 */
-    ucx_map_cstr_put(map, "Key0", &td[0]); /* 0 */
-    ucx_map_cstr_put(map, "Key1", &td[1]); /* 3 */
-    ucx_map_cstr_put(map, "KeY3", &td[3]); /* 2 */
-    ucx_map_cstr_put(map, "KEY4", &td[4]); /* 0 */
+    ucx_map_cstr_put(map, "Key2", &td[2]);
+    ucx_map_cstr_put(map, "Key0", &td[0]);
+    ucx_map_cstr_put(map, "Key1", &td[1]);
+    ucx_map_cstr_put(map, "KeY3", &td[3]);
+    ucx_map_cstr_put(map, "KEY4", &td[4]);
     UCX_TEST_BEGIN
 
     td[0] = *((int*)ucx_map_cstr_get(map, "Key0"));

mercurial