test/map_tests.c

changeset 206
58b77eb51afd
parent 192
1e51558b9d09
child 225
a1a068c2c4ef
     1.1 --- a/test/map_tests.c	Tue May 19 17:01:28 2015 +0200
     1.2 +++ b/test/map_tests.c	Thu Oct 15 12:34:10 2015 +0200
     1.3 @@ -163,6 +163,37 @@
     1.4      ucx_map_free(map);
     1.5  }
     1.6  
     1.7 +UCX_TEST(test_ucx_map_clear) {
     1.8 +    UcxMap *map = ucx_map_new(4);
     1.9 +
    1.10 +    int value = 42;
    1.11 +
    1.12 +    ucx_map_cstr_put(map, "Key0", &value);
    1.13 +    ucx_map_cstr_put(map, "Key1", &value);
    1.14 +    ucx_map_cstr_put(map, "Key2", &value);
    1.15 +    ucx_map_cstr_put(map, "Key3", &value);
    1.16 +    ucx_map_cstr_put(map, "Key4", &value);
    1.17 +    ucx_map_cstr_put(map, "Key5", &value);
    1.18 +    ucx_map_cstr_put(map, "Key6", &value);
    1.19 +    UCX_TEST_BEGIN
    1.20 +        
    1.21 +    ucx_map_clear(map);
    1.22 +
    1.23 +    UCX_TEST_ASSERT(map->count == 0, "map has not been cleared");
    1.24 +    UCX_TEST_ASSERT(map->size == 4, "map size has changed unexpectedly");
    1.25 +
    1.26 +    UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key0")==NULL, "element not removed");
    1.27 +    UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key1")==NULL, "element not removed");
    1.28 +    UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key2")==NULL, "element not removed");
    1.29 +    UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key3")==NULL, "element not removed");
    1.30 +    UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key4")==NULL, "element not removed");
    1.31 +    UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key5")==NULL, "element not removed");
    1.32 +    UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key6")==NULL, "element not removed");
    1.33 +
    1.34 +    UCX_TEST_END
    1.35 +    ucx_map_free(map);
    1.36 +}
    1.37 +
    1.38  UCX_TEST_SUBROUTINE(test_ucx_map_itersrt, UcxMap *map) {
    1.39      int v1 = 10;
    1.40      int v2 = 15;

mercurial