test/map_tests.c

changeset 34
0dcd2ca2a223
parent 33
9c219a62070d
child 40
583718dd4cf3
equal deleted inserted replaced
33:9c219a62070d 34:0dcd2ca2a223
66 UCX_TEST_END 66 UCX_TEST_END
67 ucx_map_free(map); 67 ucx_map_free(map);
68 } 68 }
69 69
70 UCX_TEST_IMPLEMENT(test_ucx_map_get) { 70 UCX_TEST_IMPLEMENT(test_ucx_map_get) {
71 UcxMap *map = ucx_map_new(4);
72
73 int td[5];
74 td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000;
75
76 ucx_map_cstr_put(map, "Key2", &td[2]); /* 0 */
77 ucx_map_cstr_put(map, "Key0", &td[0]); /* 0 */
78 ucx_map_cstr_put(map, "Key1", &td[1]); /* 3 */
79 ucx_map_cstr_put(map, "KeY3", &td[3]); /* 2 */
80 ucx_map_cstr_put(map, "KEY4", &td[4]); /* 0 */
71 UCX_TEST_BEGIN 81 UCX_TEST_BEGIN
72 UCX_TEST_ASSERT(0, "not implemented"); 82
83 td[0] = *((int*)ucx_map_cstr_get(map, "Key0"));
84 td[1] = *((int*)ucx_map_cstr_get(map, "Key1"));
85 td[2] = *((int*)ucx_map_cstr_get(map, "Key2"));
86 td[3] = *((int*)ucx_map_cstr_get(map, "KeY3"));
87 td[4] = *((int*)ucx_map_cstr_get(map, "KEY4"));
88 UCX_TEST_ASSERT(td[0] == 10, "failed key 0")
89 UCX_TEST_ASSERT(td[1] == 42, "failed key 1")
90 UCX_TEST_ASSERT(td[2] == 70, "failed key 2")
91 UCX_TEST_ASSERT(td[3] == 11200, "failed key 3")
92 UCX_TEST_ASSERT(td[4] == 80000, "failed key 4")
93
73 UCX_TEST_END 94 UCX_TEST_END
95 ucx_map_free(map);
74 } 96 }
75 97
76 UCX_TEST_SUBROUTINE(test_ucx_map_itersrt, mapptr) { 98 UCX_TEST_SUBROUTINE(test_ucx_map_itersrt, mapptr) {
77 UcxMap *map = (UcxMap*) mapptr; 99 UcxMap *map = (UcxMap*) mapptr;
78 int v1 = 10; 100 int v1 = 10;

mercurial