test/map_tests.c

Mon, 30 Dec 2019 09:54:10 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 30 Dec 2019 09:54:10 +0100
changeset 389
92e482410453
parent 374
be77fb2da242
permissions
-rw-r--r--

Added tag v2.1 for changeset 871a8ffe6c9d

20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
259
2f5dea574a75 modules documentation
Mike Becker <universe@uap-core.de>
parents: 250
diff changeset
4 * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
103
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
5 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
6 * Redistribution and use in source and binary forms, with or without
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
7 * modification, are permitted provided that the following conditions are met:
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
8 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
10 * notice, this list of conditions and the following disclaimer.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
11 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
14 * documentation and/or other materials provided with the distribution.
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
15 *
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
08018864fb91 added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents: 95
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include "map_tests.h"
374
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
30 #include <ucx/utils.h>
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
32 UCX_TEST(test_ucx_map_new) {
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 UcxMap *map = ucx_map_new(16);
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
34 UCX_TEST_BEGIN
40
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
35 UCX_TEST_ASSERT(map->size == 16, "wrong size");
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
36 UCX_TEST_ASSERT(map->map != NULL, "failed");
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
37
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
38 UCX_TEST_END
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
39 ucx_map_free(map);
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
40 }
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
42 UCX_TEST(test_ucx_key) {
327
fbc33813265b UcxMap now separates internal non-const keys from public const keys
Mike Becker <universe@uap-core.de>
parents: 259
diff changeset
43 UcxKey key = ucx_key("This is a text.", 15);
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
44 UCX_TEST_BEGIN
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
45 UCX_TEST_ASSERT(strncmp((const char*)key.data, "This is a text.", 15) == 0,
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
46 "failed");
40
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
47 UCX_TEST_ASSERT(key.len == 15, "failed");
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
48 UCX_TEST_ASSERT(key.hash == 1261186027, "hash failed");
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
49
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
50 UCX_TEST_END
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
51 }
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
52
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
53 UCX_TEST(test_ucx_map_put) {
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
54
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
55 UcxMap *map = ucx_map_new(4);
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
56
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
57 int td[5];
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
58 td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000;
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
60 UCX_TEST_BEGIN
80
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
61 ucx_map_cstr_put(map, "Key2", &td[2]); /* 3.2 */
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
62 ucx_map_cstr_put(map, "Key0", &td[0]); /* 0.0 */
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
63 ucx_map_cstr_put(map, "Key1", &td[1]); /* 3.0 */
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
64 ucx_map_cstr_put(map, "KeY3", &td[3]); /* 3.1 */
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
65 ucx_map_cstr_put(map, "KEY4", &td[4]); /* 1.0 */
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
66
40
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
67 UCX_TEST_ASSERT(*((int*)map->map[0]->data) == td[0], "failed Key0");
80
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
68 UCX_TEST_ASSERT(*((int*)map->map[1]->data) == td[4], "failed KEY4");
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
69 UCX_TEST_ASSERT(*((int*)map->map[3]->data) == td[1], "failed Key1");
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
70
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
71 UCX_TEST_ASSERT(map->map[3]->next != NULL, "no list at slot 3");
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
72 UCX_TEST_ASSERT(map->map[3]->next->next != NULL, "list corrupt at slot 3");
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
73 UCX_TEST_ASSERT(*((int*)map->map[3]->next->data) == td[3],
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
74 "failed KeY3")
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
75 UCX_TEST_ASSERT(*((int*)map->map[3]->next->next->data) == td[2],
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
76 "failed KeY2");
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
77
80
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
78 UCX_TEST_ASSERT(map->map[0]->next == NULL, "slot 0 not terminated");
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
79 UCX_TEST_ASSERT(map->map[1]->next == NULL, "slot 1 not terminated");
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
80 UCX_TEST_ASSERT(map->map[2] == NULL, "slot 2 not empty");
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
81 UCX_TEST_ASSERT(map->map[3]->next->next->next == NULL,
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
82 "slot 3 not terminated")
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
80
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
84 ucx_map_cstr_put(map, "KeY3", &td[4]); /* replace 3.1 */
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
85
80
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
86 UCX_TEST_ASSERT(*((int*)map->map[3]->data) == td[1],
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
87 "overwrite failed")
80
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
88 UCX_TEST_ASSERT(*((int*)map->map[3]->next->data) == td[4],
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
89 "overwrite failed");
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
90 UCX_TEST_ASSERT(*((int*)map->map[3]->next->next->data) == td[2],
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
91 "overwrite failed")
80
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
92 UCX_TEST_ASSERT(map->map[3]->next->next->next == NULL, "overwrite failed");
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
93
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
94 UCX_TEST_END
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
95 ucx_map_free(map);
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
96 }
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
97
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
98 UCX_TEST(test_ucx_map_get) {
34
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
99 UcxMap *map = ucx_map_new(4);
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
100
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
101 int td[5];
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
102 td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000;
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
103
80
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
104 ucx_map_cstr_put(map, "Key2", &td[2]);
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
105 ucx_map_cstr_put(map, "Key0", &td[0]);
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
106 ucx_map_cstr_put(map, "Key1", &td[1]);
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
107 ucx_map_cstr_put(map, "KeY3", &td[3]);
0125e4089f88 Fixed map tests + added some formatting options to logger
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
108 ucx_map_cstr_put(map, "KEY4", &td[4]);
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
109 UCX_TEST_BEGIN
34
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
110
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
111 td[0] = *((int*)ucx_map_cstr_get(map, "Key0"));
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
112 td[1] = *((int*)ucx_map_cstr_get(map, "Key1"));
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
113 td[2] = *((int*)ucx_map_cstr_get(map, "Key2"));
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
114 td[3] = *((int*)ucx_map_cstr_get(map, "KeY3"));
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
115 td[4] = *((int*)ucx_map_cstr_get(map, "KEY4"));
40
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
116 UCX_TEST_ASSERT(td[0] == 10, "failed key 0");
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
117 UCX_TEST_ASSERT(td[1] == 42, "failed key 1");
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
118 UCX_TEST_ASSERT(td[2] == 70, "failed key 2");
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
119 UCX_TEST_ASSERT(td[3] == 11200, "failed key 3");
583718dd4cf3 added semicolons to assert makros
Mike Becker <universe@uap-core.de>
parents: 34
diff changeset
120 UCX_TEST_ASSERT(td[4] == 80000, "failed key 4");
34
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
121
53
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
122 UCX_TEST_ASSERT(map->count == 5, "expected 5 remaining values");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
123 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key0") != NULL, "element removed");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
124
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
125 UCX_TEST_END
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
126 ucx_map_free(map);
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
127 }
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
128
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
129 UCX_TEST(test_ucx_map_remove) {
53
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
130 UcxMap *map = ucx_map_new(4);
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
131
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
132 int td[5];
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
133 td[0] = 10; td[1] = 42; td[2] = 70; td[3] = 11200; td[4] = 80000;
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
134
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
135 ucx_map_cstr_put(map, "Key2", &td[2]); /* 0 */
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
136 ucx_map_cstr_put(map, "Key0", &td[0]); /* 0 */
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
137 ucx_map_cstr_put(map, "Key1", &td[1]); /* 3 */
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
138 ucx_map_cstr_put(map, "KeY3", &td[3]); /* 2 */
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
139 ucx_map_cstr_put(map, "KEY4", &td[4]); /* 0 */
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
140 UCX_TEST_BEGIN
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
141
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
142 td[0] = *((int*)ucx_map_cstr_remove(map, "Key0"));
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
143 td[1] = *((int*)ucx_map_cstr_get(map, "Key1"));
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
144 td[2] = *((int*)ucx_map_cstr_remove(map, "Key2"));
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
145 td[3] = *((int*)ucx_map_cstr_get(map, "KeY3"));
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
146 td[4] = *((int*)ucx_map_cstr_get(map, "KEY4"));
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
147 UCX_TEST_ASSERT(td[0] == 10, "failed key 0");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
148 UCX_TEST_ASSERT(td[1] == 42, "failed key 1");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
149 UCX_TEST_ASSERT(td[2] == 70, "failed key 2");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
150 UCX_TEST_ASSERT(td[3] == 11200, "failed key 3");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
151 UCX_TEST_ASSERT(td[4] == 80000, "failed key 4");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
152
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
153 UCX_TEST_ASSERT(map->count == 3, "expected 3 remaining values");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
154 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key0")==NULL, "element not removed");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
155 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key1")!=NULL, "element removed");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
156 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key2")==NULL, "element not removed");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
157 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "KeY3")!=NULL, "element removed");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
158 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "KEY4")!=NULL, "element removed");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
159
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
160 UCX_TEST_ASSERT(ucx_map_cstr_remove(map, "Key2") == NULL,
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
161 "subsequent remove call shall return NULL");
e533c170bfb8 added ucx_map_remove
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
162
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
163 UCX_TEST_END
34
0dcd2ca2a223 completed map tests
Mike Becker <universe@uap-core.de>
parents: 33
diff changeset
164 ucx_map_free(map);
20
db7d9860dbbd added some map functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 }
29
bce0d7f2912b fixed map with the help of new tests
Mike Becker <universe@uap-core.de>
parents: 20
diff changeset
166
206
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
167 UCX_TEST(test_ucx_map_clear) {
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
168 UcxMap *map = ucx_map_new(4);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
169
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
170 int value = 42;
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
171
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
172 ucx_map_cstr_put(map, "Key0", &value);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
173 ucx_map_cstr_put(map, "Key1", &value);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
174 ucx_map_cstr_put(map, "Key2", &value);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
175 ucx_map_cstr_put(map, "Key3", &value);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
176 ucx_map_cstr_put(map, "Key4", &value);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
177 ucx_map_cstr_put(map, "Key5", &value);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
178 ucx_map_cstr_put(map, "Key6", &value);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
179 UCX_TEST_BEGIN
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
180
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
181 ucx_map_clear(map);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
182
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
183 UCX_TEST_ASSERT(map->count == 0, "map has not been cleared");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
184 UCX_TEST_ASSERT(map->size == 4, "map size has changed unexpectedly");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
185
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
186 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key0")==NULL, "element not removed");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
187 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key1")==NULL, "element not removed");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
188 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key2")==NULL, "element not removed");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
189 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key3")==NULL, "element not removed");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
190 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key4")==NULL, "element not removed");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
191 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key5")==NULL, "element not removed");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
192 UCX_TEST_ASSERT(ucx_map_cstr_get(map, "Key6")==NULL, "element not removed");
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
193
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
194 UCX_TEST_END
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
195 ucx_map_free(map);
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
196 }
58b77eb51afd added ucx_map_clean()
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
197
88
18823857ce79 variadic test subroutines
Mike Becker <universe@uap-core.de>
parents: 80
diff changeset
198 UCX_TEST_SUBROUTINE(test_ucx_map_itersrt, UcxMap *map) {
31
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
199 int v1 = 10;
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
200 int v2 = 15;
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
201 int v3 = 7;
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
202 int v4 = 9;
32
c7af4ec56e19 consequently used intptr_t in mpool tests
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
203
31
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
204 ucx_map_cstr_put(map, "v1", &v1);
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
205 ucx_map_cstr_put(map, "v2", &v2);
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
206 ucx_map_cstr_put(map, "v3", &v3);
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
207 ucx_map_cstr_put(map, "v4", &v4);
32
c7af4ec56e19 consequently used intptr_t in mpool tests
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
208
31
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
209 UcxMapIterator i = ucx_map_iterator(map);
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
210 int check = 0;
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
211 int hit = 0;
32
c7af4ec56e19 consequently used intptr_t in mpool tests
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
212
152
3238f65db163 minor code fixes + added clang support + improved build system
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
213 void* v;
111
c8c59d7f4536 new map foreach macro
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 103
diff changeset
214 UCX_MAP_FOREACH(key, v, i) {
152
3238f65db163 minor code fixes + added clang support + improved build system
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
215 check += *((int*)v);
31
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
216 hit++;
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
217 }
32
c7af4ec56e19 consequently used intptr_t in mpool tests
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
218
31
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
219 UCX_TEST_ASSERT(hit == 4, "test1: wrong number of hits");
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
220 UCX_TEST_ASSERT(check == v1+v2+v3+v4, "test1: wrong result");
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
221 }
32
c7af4ec56e19 consequently used intptr_t in mpool tests
Mike Becker <universe@uap-core.de>
parents: 31
diff changeset
222
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
223 UCX_TEST(test_ucx_map_iterator) {
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
224 UcxMap *map = ucx_map_new(16);
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
225 UCX_TEST_BEGIN
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
226 UCX_TEST_CALL_SUBROUTINE(test_ucx_map_itersrt, map)
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
227 UCX_TEST_END
31
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
228 ucx_map_free(map);
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
229 }
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
230
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
231 UCX_TEST(test_ucx_map_iterator_chain) {
33
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
232 UcxMap *map = ucx_map_new(1);
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
233 UCX_TEST_BEGIN
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
234 UCX_TEST_CALL_SUBROUTINE(test_ucx_map_itersrt, map)
9c219a62070d major refactoring of test framework
Mike Becker <universe@uap-core.de>
parents: 32
diff changeset
235 UCX_TEST_END
31
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
236 ucx_map_free(map);
91ac86557290 added map iterator
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
237 }
42
ff3dd1ee7dee (broken-commit) - added load and store functions, tests failing
Mike Becker <universe@uap-core.de>
parents: 41
diff changeset
238
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
239 UCX_TEST(test_ucx_map_clone) {
44
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
240 UcxMap *map = ucx_map_new(4);
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
241
71
303dabadff1c made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
242 ucx_map_cstr_put(map, "key1", (void*)"value1");
303dabadff1c made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
243 ucx_map_cstr_put(map, "key2", (void*)"value2");
303dabadff1c made the code work with g++ without errors (but warnings)
Mike Becker <universe@uap-core.de>
parents: 69
diff changeset
244 ucx_map_cstr_put(map, "key3", (void*)"value3");
44
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
245
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
246 UcxMap *clone = ucx_map_clone(map, NULL, NULL);
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
247
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
248 const char *v1 = (const char *) ucx_map_cstr_get(map, "key1");
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
249 const char *v2 = (const char *) ucx_map_cstr_get(map, "key2");
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
250 const char *v3 = (const char *) ucx_map_cstr_get(map, "key3");
44
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
251
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
252 UCX_TEST_BEGIN
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
253
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
254 UCX_TEST_ASSERT(v1 != NULL, "failed key 1");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
255 UCX_TEST_ASSERT(v2 != NULL, "failed key 2");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
256 UCX_TEST_ASSERT(v3 != NULL, "failed key 3");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
257
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
258 const char *c1 = (const char *) ucx_map_cstr_get(clone, "key1");
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
259 const char *c2 = (const char *) ucx_map_cstr_get(clone, "key2");
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
260 const char *c3 = (const char *) ucx_map_cstr_get(clone, "key3");
44
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
261
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
262 UCX_TEST_ASSERT(c1 != NULL, "failed key 1 (clone)");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
263 UCX_TEST_ASSERT(c2 != NULL, "failed key 2 (clone)");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
264 UCX_TEST_ASSERT(c3 != NULL, "failed key 3 (clone)");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
265
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
266 UCX_TEST_ASSERT(strcmp(c1, v1) == 0, "value error for key1");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
267 UCX_TEST_ASSERT(strcmp(c2, v2) == 0, "value error for key2");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
268 UCX_TEST_ASSERT(strcmp(c3, v3) == 0, "value error for key3");
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
269
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
270 UCX_TEST_END
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
271
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
272 ucx_map_free(map);
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
273 ucx_map_free(clone);
46356d74e873 added map clone
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
274 }
51
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
275
134
4d320dc3a7af documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents: 112
diff changeset
276 UCX_TEST(test_ucx_map_rehash) {
51
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
277 UcxMap *map = ucx_map_new(4);
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
278
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
279 char keys[10][5];
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
280 char values[10][7];
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
281 for (int i = 0 ; i < 10 ; i++) {
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
282 strcpy(keys[i], "key");
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
283 keys[i][3] = 48+i; keys[i][4] = 0;
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
284 strcpy(values[i], "value");
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
285 values[i][5] = 48+i; values[i][6] = 0;
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
286
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
287 ucx_map_cstr_put(map, keys[i], values[i]);
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
288 }
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
289
52
34f50d0bada4 added ucx_map_copy and fixed ucx_map_rehash
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
290 ucx_map_rehash(map);
51
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
291
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
292 UCX_TEST_BEGIN
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
293 UCX_TEST_ASSERT(map->size == 25, "new capacity shall be 2.5 * count");
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
294 UCX_TEST_ASSERT(map->count == 10, "new map element count incorrect");
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
295 for (int i = 0 ; i < 10 ; i++) {
69
fb59270b1de3 made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents: 55
diff changeset
296 const char *value = (const char *) ucx_map_cstr_get(map, keys[i]);
51
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
297 UCX_TEST_ASSERT(value != NULL, "new map is missing old keys");
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
298 UCX_TEST_ASSERT(strncmp(value, values[i], 6) == 0,
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
299 "new map contains incorrect values");
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
300 }
52
34f50d0bada4 added ucx_map_copy and fixed ucx_map_rehash
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
301 ucx_map_rehash(map);
34f50d0bada4 added ucx_map_copy and fixed ucx_map_rehash
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 51
diff changeset
302 UCX_TEST_ASSERT(map->size == 25,
51
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
303 "subsequent rehashing call shall not change size");
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
304 UCX_TEST_END
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
305
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
306 ucx_map_free(map);
1c78cd19fb6b added rehashing to maps by using clone function
Mike Becker <universe@uap-core.de>
parents: 48
diff changeset
307 }
374
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
308
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
309 UCX_TEST(test_ucx_map_union) {
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
310 int td[5];
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
311 size_t intlen = sizeof(int);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
312 td[0] = 10; td[1] = 42; td[2] = 47; td[3] = 1337; td[4] = 9000;
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
313
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
314 UcxMap *first = ucx_map_new(4);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
315 UcxMap *second = ucx_map_new(4);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
316
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
317 ucx_map_cstr_put(first, "key0", &td[0]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
318 ucx_map_cstr_put(first, "key1", &td[1]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
319 ucx_map_cstr_put(second, "key2", &td[2]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
320 ucx_map_cstr_put(second, "key0", &td[3]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
321 ucx_map_cstr_put(second, "key3", &td[4]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
322
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
323 UcxMap *result = ucx_map_union(first, second, ucx_memcpy, &intlen);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
324
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
325 UCX_TEST_BEGIN
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
326
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
327 int* r;
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
328 UCX_TEST_ASSERT(result->count == 4,
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
329 "result has incorrect number of elements");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
330
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
331 r = (int*)ucx_map_cstr_get(result, "key0");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
332 UCX_TEST_ASSERT(!!r, "key0 is not present");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
333 UCX_TEST_ASSERT(*r == td[3], "key0 has not been overwritten");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
334 r = (int*)ucx_map_cstr_get(result, "key1");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
335 UCX_TEST_ASSERT(!!r, "key1 is not present");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
336 UCX_TEST_ASSERT(*r == td[1], "key1 contains wrong data");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
337 r = (int*)ucx_map_cstr_get(result, "key2");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
338 UCX_TEST_ASSERT(!!r, "key2 is not present");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
339 UCX_TEST_ASSERT(*r == td[2], "key2 contains wrong data");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
340 r = (int*)ucx_map_cstr_get(result, "key3");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
341 UCX_TEST_ASSERT(!!r, "key3 is not present");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
342 UCX_TEST_ASSERT(*r == td[4], "key3 contains wrong data");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
343
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
344 UCX_TEST_END
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
345
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
346 ucx_map_free_content(result, NULL);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
347 ucx_map_free(result);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
348 ucx_map_free(second);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
349 ucx_map_free(first);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
350 }
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
351
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
352 UCX_TEST(test_ucx_map_intersection) {
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
353 int td[5];
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
354 size_t intlen = sizeof(int);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
355 td[0] = 10; td[1] = 42; td[2] = 47; td[3] = 1337; td[4] = 9000;
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
356
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
357 UcxMap *first = ucx_map_new(4);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
358 UcxMap *second = ucx_map_new(4);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
359
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
360 ucx_map_cstr_put(first, "key0", &td[0]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
361 ucx_map_cstr_put(first, "key1", &td[1]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
362 ucx_map_cstr_put(first, "key4", &td[3]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
363 ucx_map_cstr_put(second, "key2", &td[2]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
364 ucx_map_cstr_put(second, "key0", &td[3]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
365 ucx_map_cstr_put(second, "key3", &td[4]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
366 ucx_map_cstr_put(second, "key4", &td[4]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
367
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
368 UcxMap *result = ucx_map_intersection(first, second,
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
369 ucx_memcpy, &intlen);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
370
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
371 UCX_TEST_BEGIN
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
372
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
373 int* r;
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
374 UCX_TEST_ASSERT(result->count == 2,
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
375 "result has incorrect number of elements");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
376
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
377 r = (int*)ucx_map_cstr_get(result, "key0");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
378 UCX_TEST_ASSERT(!!r, "key0 is not present");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
379 UCX_TEST_ASSERT(*r == td[0], "key0 has not original data");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
380 r = (int*)ucx_map_cstr_get(result, "key4");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
381 UCX_TEST_ASSERT(!!r, "key4 is not present");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
382 UCX_TEST_ASSERT(*r == td[3], "key4 has not original data");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
383
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
384 UCX_TEST_END
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
385
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
386 ucx_map_free_content(result, NULL);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
387 ucx_map_free(result);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
388 ucx_map_free(second);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
389 ucx_map_free(first);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
390 }
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
391
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
392
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
393 UCX_TEST(test_ucx_map_difference) {
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
394 int td[5];
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
395 size_t intlen = sizeof(int);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
396 td[0] = 10; td[1] = 42; td[2] = 47; td[3] = 1337; td[4] = 9000;
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
397
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
398 UcxMap *first = ucx_map_new(4);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
399 UcxMap *second = ucx_map_new(4);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
400
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
401 ucx_map_cstr_put(first, "key0", &td[0]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
402 ucx_map_cstr_put(first, "key1", &td[1]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
403 ucx_map_cstr_put(first, "key2", &td[2]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
404 ucx_map_cstr_put(first, "key4", &td[3]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
405 ucx_map_cstr_put(second, "key0", &td[3]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
406 ucx_map_cstr_put(second, "key3", &td[4]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
407 ucx_map_cstr_put(second, "key4", &td[4]);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
408
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
409 UcxMap *result = ucx_map_difference(first, second, ucx_memcpy, &intlen);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
410
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
411 UCX_TEST_BEGIN
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
412
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
413 int* r;
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
414 UCX_TEST_ASSERT(result->count == 2,
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
415 "result has incorrect number of elements");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
416
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
417 r = (int*)ucx_map_cstr_get(result, "key1");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
418 UCX_TEST_ASSERT(!!r, "key1 is not present");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
419 UCX_TEST_ASSERT(*r == td[1], "key1 has incorrect data");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
420 r = (int*)ucx_map_cstr_get(result, "key2");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
421 UCX_TEST_ASSERT(!!r, "key2 is not present");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
422 UCX_TEST_ASSERT(*r == td[2], "key2 has incorrect data");
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
423
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
424 UCX_TEST_END
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
425
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
426 ucx_map_free_content(result, NULL);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
427 ucx_map_free(result);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
428 ucx_map_free(second);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
429 ucx_map_free(first);
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
430 }
be77fb2da242 adds set operations for UcxMap
Mike Becker <universe@uap-core.de>
parents: 327
diff changeset
431

mercurial