26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 */ |
27 */ |
28 |
28 |
29 #include "map_tests.h" |
29 #include "map_tests.h" |
30 |
30 |
31 UCX_TEST_IMPLEMENT(test_ucx_map_new) { |
31 UCX_TEST(test_ucx_map_new) { |
32 UcxMap *map = ucx_map_new(16); |
32 UcxMap *map = ucx_map_new(16); |
33 UCX_TEST_BEGIN |
33 UCX_TEST_BEGIN |
34 UCX_TEST_ASSERT(map->size == 16, "wrong size"); |
34 UCX_TEST_ASSERT(map->size == 16, "wrong size"); |
35 UCX_TEST_ASSERT(map->map != NULL, "failed"); |
35 UCX_TEST_ASSERT(map->map != NULL, "failed"); |
36 |
36 |
37 UCX_TEST_END |
37 UCX_TEST_END |
38 ucx_map_free(map); |
38 ucx_map_free(map); |
39 } |
39 } |
40 |
40 |
41 UCX_TEST_IMPLEMENT(test_ucx_key) { |
41 UCX_TEST(test_ucx_key) { |
42 UcxKey key = ucx_key((void*)"This is a text.", 15); |
42 UcxKey key = ucx_key((void*)"This is a text.", 15); |
43 UCX_TEST_BEGIN |
43 UCX_TEST_BEGIN |
44 UCX_TEST_ASSERT(strncmp((const char*)key.data, "This is a text.", 15) == 0, |
44 UCX_TEST_ASSERT(strncmp((const char*)key.data, "This is a text.", 15) == 0, |
45 "failed"); |
45 "failed"); |
46 UCX_TEST_ASSERT(key.len == 15, "failed"); |
46 UCX_TEST_ASSERT(key.len == 15, "failed"); |
47 UCX_TEST_ASSERT(key.hash == 1261186027, "hash failed"); |
47 UCX_TEST_ASSERT(key.hash == 1261186027, "hash failed"); |
48 |
48 |
49 UCX_TEST_END |
49 UCX_TEST_END |
50 } |
50 } |
51 |
51 |
52 UCX_TEST_IMPLEMENT(test_ucx_map_put) { |
52 UCX_TEST(test_ucx_map_put) { |
53 |
53 |
54 UcxMap *map = ucx_map_new(4); |
54 UcxMap *map = ucx_map_new(4); |
55 |
55 |
56 int td[5]; |
56 int td[5]; |
57 td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000; |
57 td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000; |
186 |
186 |
187 UCX_TEST_ASSERT(hit == 4, "test1: wrong number of hits"); |
187 UCX_TEST_ASSERT(hit == 4, "test1: wrong number of hits"); |
188 UCX_TEST_ASSERT(check == v1+v2+v3+v4, "test1: wrong result"); |
188 UCX_TEST_ASSERT(check == v1+v2+v3+v4, "test1: wrong result"); |
189 } |
189 } |
190 |
190 |
191 UCX_TEST_IMPLEMENT(test_ucx_map_iterator) { |
191 UCX_TEST(test_ucx_map_iterator) { |
192 UcxMap *map = ucx_map_new(16); |
192 UcxMap *map = ucx_map_new(16); |
193 UCX_TEST_BEGIN |
193 UCX_TEST_BEGIN |
194 UCX_TEST_CALL_SUBROUTINE(test_ucx_map_itersrt, map) |
194 UCX_TEST_CALL_SUBROUTINE(test_ucx_map_itersrt, map) |
195 UCX_TEST_END |
195 UCX_TEST_END |
196 ucx_map_free(map); |
196 ucx_map_free(map); |
197 } |
197 } |
198 |
198 |
199 UCX_TEST_IMPLEMENT(test_ucx_map_iterator_chain) { |
199 UCX_TEST(test_ucx_map_iterator_chain) { |
200 UcxMap *map = ucx_map_new(1); |
200 UcxMap *map = ucx_map_new(1); |
201 UCX_TEST_BEGIN |
201 UCX_TEST_BEGIN |
202 UCX_TEST_CALL_SUBROUTINE(test_ucx_map_itersrt, map) |
202 UCX_TEST_CALL_SUBROUTINE(test_ucx_map_itersrt, map) |
203 UCX_TEST_END |
203 UCX_TEST_END |
204 ucx_map_free(map); |
204 ucx_map_free(map); |
205 } |
205 } |
206 |
206 |
207 UCX_TEST_IMPLEMENT(test_ucx_map_clone) { |
207 UCX_TEST(test_ucx_map_clone) { |
208 UcxMap *map = ucx_map_new(4); |
208 UcxMap *map = ucx_map_new(4); |
209 |
209 |
210 ucx_map_cstr_put(map, "key1", (void*)"value1"); |
210 ucx_map_cstr_put(map, "key1", (void*)"value1"); |
211 ucx_map_cstr_put(map, "key2", (void*)"value2"); |
211 ucx_map_cstr_put(map, "key2", (void*)"value2"); |
212 ucx_map_cstr_put(map, "key3", (void*)"value3"); |
212 ucx_map_cstr_put(map, "key3", (void*)"value3"); |