test/avl_tests.c

changeset 312
e1e3b768ae8b
parent 259
2f5dea574a75
child 330
d2bbf907a189
equal deleted inserted replaced
311:e1f3248576bc 312:e1e3b768ae8b
73 73
74 return 1; 74 return 1;
75 } 75 }
76 76
77 UCX_TEST(test_ucx_avl_put) { 77 UCX_TEST(test_ucx_avl_put) {
78 UcxAVLTree *tree1 = ucx_avl_new(ucx_ptrcmp); 78 UcxAVLTree *tree1 = ucx_avl_new(ucx_cmp_ptr);
79 UcxAVLTree *tree2 = ucx_avl_new(ucx_ptrcmp); 79 UcxAVLTree *tree2 = ucx_avl_new(ucx_cmp_ptr);
80 UcxAVLTree *tree3 = ucx_avl_new(ucx_ptrcmp); 80 UcxAVLTree *tree3 = ucx_avl_new(ucx_cmp_ptr);
81 UcxAVLTree *tree4 = ucx_avl_new(ucx_ptrcmp); 81 UcxAVLTree *tree4 = ucx_avl_new(ucx_cmp_ptr);
82 UcxAVLTree *tree5 = ucx_avl_new(ucx_ptrcmp); 82 UcxAVLTree *tree5 = ucx_avl_new(ucx_cmp_ptr);
83 83
84 char *data1 = (char*)"data1"; 84 char *data1 = (char*)"data1";
85 char *data2 = (char*)"data2"; 85 char *data2 = (char*)"data2";
86 char *data3 = (char*)"data3"; 86 char *data3 = (char*)"data3";
87 87
142 ucx_avl_free(tree4); 142 ucx_avl_free(tree4);
143 ucx_avl_free(tree5); 143 ucx_avl_free(tree5);
144 } 144 }
145 145
146 UCX_TEST(test_ucx_avl_remove) { 146 UCX_TEST(test_ucx_avl_remove) {
147 UcxAVLTree *tree1 = ucx_avl_new(ucx_ptrcmp); 147 UcxAVLTree *tree1 = ucx_avl_new(ucx_cmp_ptr);
148 UcxAVLTree *tree2 = ucx_avl_new(ucx_ptrcmp); 148 UcxAVLTree *tree2 = ucx_avl_new(ucx_cmp_ptr);
149 UcxAVLTree *tree3 = ucx_avl_new(ucx_ptrcmp); 149 UcxAVLTree *tree3 = ucx_avl_new(ucx_cmp_ptr);
150 UcxAVLTree *tree4 = ucx_avl_new(ucx_ptrcmp); 150 UcxAVLTree *tree4 = ucx_avl_new(ucx_cmp_ptr);
151 151
152 char *data1 = (char*)"data1"; 152 char *data1 = (char*)"data1";
153 char *data2 = (char*)"data2"; 153 char *data2 = (char*)"data2";
154 char *data3 = (char*)"data3"; 154 char *data3 = (char*)"data3";
155 155
227 static intmax_t dist_int(const void* a, const void* b, void* n) { 227 static intmax_t dist_int(const void* a, const void* b, void* n) {
228 return ((intmax_t)a)-((intmax_t)b); 228 return ((intmax_t)a)-((intmax_t)b);
229 } 229 }
230 230
231 UCX_TEST(test_ucx_avl_find) { 231 UCX_TEST(test_ucx_avl_find) {
232 UcxAVLTree *tree = ucx_avl_new(ucx_ptrcmp); 232 UcxAVLTree *tree = ucx_avl_new(ucx_cmp_ptr);
233 233
234 size_t len = 12; 234 size_t len = 12;
235 int val[] = {10, 15, 3, 4, -30, 20, 14, -11, 12, -5, 1, 13}; 235 int val[] = {10, 15, 3, 4, -30, 20, 14, -11, 12, -5, 1, 13};
236 236
237 for (size_t i = 0 ; i < len ; i++) { 237 for (size_t i = 0 ; i < len ; i++) {
282 282
283 ucx_avl_free(tree); 283 ucx_avl_free(tree);
284 } 284 }
285 285
286 UCX_TEST(test_ucx_avl_traverse) { 286 UCX_TEST(test_ucx_avl_traverse) {
287 UcxAVLTree *tree = ucx_avl_new(ucx_ptrcmp); 287 UcxAVLTree *tree = ucx_avl_new(ucx_cmp_ptr);
288 288
289 size_t len = 12; 289 size_t len = 12;
290 290
291 int val[] = {10, 15, 3, 4, -30, 20, 14, -11, 12, -5, 1, 13}; 291 int val[] = {10, 15, 3, 4, -30, 20, 14, -11, 12, -5, 1, 13};
292 int val_ordered[] = {-30, -11, -5, 1, 3, 4, 10, 12, 13, 14, 15, 20}; 292 int val_ordered[] = {-30, -11, -5, 1, 3, 4, 10, 12, 13, 14, 15, 20};

mercurial