test/avl_tests.c

changeset 204
4477987d40cd
parent 203
3d999ea3f780
child 225
a1a068c2c4ef
equal deleted inserted replaced
203:3d999ea3f780 204:4477987d40cd
155 155
156 UCX_TEST_BEGIN 156 UCX_TEST_BEGIN
157 ucx_avl_put(tree1, 2, (char*)data2); 157 ucx_avl_put(tree1, 2, (char*)data2);
158 ucx_avl_put(tree1, 1, (char*)data1); 158 ucx_avl_put(tree1, 1, (char*)data1);
159 ucx_avl_put(tree1, 3, (char*)data3); 159 ucx_avl_put(tree1, 3, (char*)data3);
160 void *val = ucx_avl_remove(tree1, 3); 160 void *val;
161 161 ucx_avl_remove_s(tree1, 3, NULL, &val);
162 UCX_TEST_ASSERT(check_tree(tree1->root), "check_tree failed (tree1)"); 162
163 UCX_TEST_ASSERT( 163 UCX_TEST_ASSERT(check_tree(tree1->root), "check_tree failed (tree1)");
164 val == data3, 164 UCX_TEST_ASSERT(val == data3,
165 "wrong return value for key: 1 (tree1)"); 165 "wrong return value for key: 1 (tree1)");
166 UCX_TEST_ASSERT(ucx_avl_get(tree1, 3) == NULL, "value not removed (tree1)"); 166 UCX_TEST_ASSERT(ucx_avl_get(tree1, 3) == NULL, "value not removed (tree1)");
167 UCX_TEST_ASSERT( 167
168 ucx_avl_remove(tree1, 2) == data2, 168 ucx_avl_remove_s(tree1, 2, NULL, &val);
169 UCX_TEST_ASSERT(val == data2,
169 "wrong return value for key: 2 (tree1)"); 170 "wrong return value for key: 2 (tree1)");
170 UCX_TEST_ASSERT(check_tree(tree1->root), "check_tree failed (tree1)"); 171 UCX_TEST_ASSERT(check_tree(tree1->root), "check_tree failed (tree1)");
171 UCX_TEST_ASSERT( 172
172 ucx_avl_remove(tree1, 1) == data1, 173 ucx_avl_remove_s(tree1, 1, NULL, &val);
174 UCX_TEST_ASSERT(val == data1,
173 "wrong return value for key: 1 (tree1)"); 175 "wrong return value for key: 1 (tree1)");
174 UCX_TEST_ASSERT(check_tree(tree1->root), "check_tree failed (tree1)"); 176 UCX_TEST_ASSERT(check_tree(tree1->root), "check_tree failed (tree1)");
175 UCX_TEST_ASSERT(tree1->root == NULL, "root not NULL (tree1)"); 177 UCX_TEST_ASSERT(tree1->root == NULL, "root not NULL (tree1)");
176 178
177 179
183 } else { 185 } else {
184 ucx_avl_put(tree2, i, data1); 186 ucx_avl_put(tree2, i, data1);
185 } 187 }
186 } 188 }
187 189
188 UCX_TEST_ASSERT( 190 ucx_avl_remove_s(tree2, 10, NULL, &val);
189 ucx_avl_remove(tree2, 10) == data3, 191 UCX_TEST_ASSERT(val == data3,
190 "wrong return value for key: 10 (tree2)"); 192 "wrong return value for key: 10 (tree2)");
191 UCX_TEST_ASSERT(check_tree(tree2->root), "check_tree failed (tree2)"); 193 UCX_TEST_ASSERT(check_tree(tree2->root), "check_tree failed (tree2)");
192 194
193 UCX_TEST_ASSERT( 195 ucx_avl_remove_s(tree2, 15, NULL, &val);
194 ucx_avl_remove(tree2, 15) == data2, 196 UCX_TEST_ASSERT(val == data2,
195 "wrong return value for key: 15 (tree2)"); 197 "wrong return value for key: 15 (tree2)");
196 UCX_TEST_ASSERT(check_tree(tree2->root), "check_tree failed (tree2)"); 198 UCX_TEST_ASSERT(check_tree(tree2->root), "check_tree failed (tree2)");
197 199
198 for(int i=0;i<20;i++) { 200 for(int i=0;i<20;i++) {
199 ucx_avl_remove(tree2, i); 201 ucx_avl_remove(tree2, i);

mercurial