test/map_tests.c

changeset 80
0125e4089f88
parent 76
655020a30e77
child 88
18823857ce79
     1.1 --- a/test/map_tests.c	Wed Feb 06 14:31:44 2013 +0100
     1.2 +++ b/test/map_tests.c	Wed Feb 06 14:35:15 2013 +0100
     1.3 @@ -33,36 +33,38 @@
     1.4      td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000;
     1.5  
     1.6      UCX_TEST_BEGIN
     1.7 -    ucx_map_cstr_put(map, "Key2", &td[2]); /* 0 */
     1.8 -    ucx_map_cstr_put(map, "Key0", &td[0]); /* 0 */
     1.9 -    ucx_map_cstr_put(map, "Key1", &td[1]); /* 3 */
    1.10 -    ucx_map_cstr_put(map, "KeY3", &td[3]); /* 2 */
    1.11 -    ucx_map_cstr_put(map, "KEY4", &td[4]); /* 0 */
    1.12 +    ucx_map_cstr_put(map, "Key2", &td[2]); /* 3.2 */
    1.13 +    ucx_map_cstr_put(map, "Key0", &td[0]); /* 0.0 */
    1.14 +    ucx_map_cstr_put(map, "Key1", &td[1]); /* 3.0 */
    1.15 +    ucx_map_cstr_put(map, "KeY3", &td[3]); /* 3.1 */
    1.16 +    ucx_map_cstr_put(map, "KEY4", &td[4]); /* 1.0 */
    1.17      
    1.18      UCX_TEST_ASSERT(*((int*)map->map[0]->data) == td[0], "failed Key0");
    1.19 -    UCX_TEST_ASSERT(map->map[0]->next != NULL, "no list at slot 0");
    1.20 -    UCX_TEST_ASSERT(*((int*)map->map[0]->next->data) == td[2], "failed Key2");
    1.21 -    UCX_TEST_ASSERT(map->map[0]->next->next != NULL, "list corrupt at slot 0");
    1.22 -    UCX_TEST_ASSERT(*((int*)map->map[0]->next->next->data) == td[4],
    1.23 -            "failed Key4")
    1.24 -    UCX_TEST_ASSERT(map->map[0]->next->next->next == NULL,
    1.25 -            "slot 0 not terminated")
    1.26 +    UCX_TEST_ASSERT(*((int*)map->map[1]->data) == td[4], "failed KEY4");
    1.27 +    UCX_TEST_ASSERT(*((int*)map->map[3]->data) == td[1], "failed Key1");
    1.28 +    
    1.29 +    UCX_TEST_ASSERT(map->map[3]->next != NULL, "no list at slot 3");
    1.30 +    UCX_TEST_ASSERT(map->map[3]->next->next != NULL, "list corrupt at slot 3");
    1.31 +    UCX_TEST_ASSERT(*((int*)map->map[3]->next->data) == td[3],
    1.32 +            "failed KeY3")
    1.33 +    UCX_TEST_ASSERT(*((int*)map->map[3]->next->next->data) == td[2],
    1.34 +            "failed KeY2");
    1.35  
    1.36 -    UCX_TEST_ASSERT(map->map[1] == NULL, "slot 1 not terminated");
    1.37 +    UCX_TEST_ASSERT(map->map[0]->next == NULL, "slot 0 not terminated");
    1.38 +    UCX_TEST_ASSERT(map->map[1]->next == NULL, "slot 1 not terminated");
    1.39 +    UCX_TEST_ASSERT(map->map[2] == NULL, "slot 2 not empty");
    1.40 +    UCX_TEST_ASSERT(map->map[3]->next->next->next == NULL,
    1.41 +            "slot 3 not terminated")
    1.42  
    1.43 -    UCX_TEST_ASSERT(*((int*)map->map[2]->data) == td[3], "failed KeY3");
    1.44 -    UCX_TEST_ASSERT(map->map[2]->next == NULL, "slot 2 not terminated");
    1.45 -
    1.46 -    UCX_TEST_ASSERT(*((int*)map->map[3]->data) == td[1], "failed Key1");
    1.47 -
    1.48 -    ucx_map_cstr_put(map, "Key0", &td[3]); /* 0 */
    1.49 +    ucx_map_cstr_put(map, "KeY3", &td[4]); /* replace 3.1 */
    1.50      
    1.51 -    UCX_TEST_ASSERT(*((int*)map->map[0]->data) == td[3], "overwrite failed");
    1.52 -    UCX_TEST_ASSERT(*((int*)map->map[0]->next->data) == td[2],
    1.53 +    UCX_TEST_ASSERT(*((int*)map->map[3]->data) == td[1],
    1.54              "overwrite failed")
    1.55 -    UCX_TEST_ASSERT(*((int*)map->map[0]->next->next->data) == td[4], 
    1.56 +    UCX_TEST_ASSERT(*((int*)map->map[3]->next->data) == td[4],
    1.57 +            "overwrite failed");
    1.58 +    UCX_TEST_ASSERT(*((int*)map->map[3]->next->next->data) == td[2], 
    1.59              "overwrite failed")
    1.60 -    UCX_TEST_ASSERT(map->map[0]->next->next->next == NULL, "overwrite failed");
    1.61 +    UCX_TEST_ASSERT(map->map[3]->next->next->next == NULL, "overwrite failed");
    1.62      
    1.63      UCX_TEST_END
    1.64      ucx_map_free(map);
    1.65 @@ -74,11 +76,11 @@
    1.66      int td[5];
    1.67      td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000;
    1.68  
    1.69 -    ucx_map_cstr_put(map, "Key2", &td[2]); /* 0 */
    1.70 -    ucx_map_cstr_put(map, "Key0", &td[0]); /* 0 */
    1.71 -    ucx_map_cstr_put(map, "Key1", &td[1]); /* 3 */
    1.72 -    ucx_map_cstr_put(map, "KeY3", &td[3]); /* 2 */
    1.73 -    ucx_map_cstr_put(map, "KEY4", &td[4]); /* 0 */
    1.74 +    ucx_map_cstr_put(map, "Key2", &td[2]);
    1.75 +    ucx_map_cstr_put(map, "Key0", &td[0]);
    1.76 +    ucx_map_cstr_put(map, "Key1", &td[1]);
    1.77 +    ucx_map_cstr_put(map, "KeY3", &td[3]);
    1.78 +    ucx_map_cstr_put(map, "KEY4", &td[4]);
    1.79      UCX_TEST_BEGIN
    1.80  
    1.81      td[0] = *((int*)ucx_map_cstr_get(map, "Key0"));

mercurial