# HG changeset patch # User Olaf Wintermann # Date 1538164050 -7200 # Node ID d2bbf907a189747b7f68223c480fd9bf9563c956 # Parent 71e9a60abfb4ad89e6a6e4485a95fae2a6ea2251 adds some additional avl tree tests diff -r 71e9a60abfb4 -r d2bbf907a189 test/avl_tests.c --- a/test/avl_tests.c Wed Aug 22 14:39:24 2018 +0200 +++ b/test/avl_tests.c Fri Sep 28 21:47:30 2018 +0200 @@ -230,6 +230,8 @@ UCX_TEST(test_ucx_avl_find) { UcxAVLTree *tree = ucx_avl_new(ucx_cmp_ptr); + UcxAVLTree *tree2 = ucx_avl_new(ucx_cmp_ptr); + UcxAVLTree *tree3 = ucx_avl_new(ucx_cmp_ptr); size_t len = 12; int val[] = {10, 15, 3, 4, -30, 20, 14, -11, 12, -5, 1, 13}; @@ -278,9 +280,25 @@ ret = ucx_avl_find(tree,(intptr_t)7, dist_int, UCX_AVL_FIND_UPPER_BOUNDED); UCX_TEST_ASSERT(ret && *((int*)ret) == 4, "AVL find UB failed"); + int val2[] = { 10, 15 }; + ucx_avl_put(tree2, val2[0], &(val2[0])); + ucx_avl_put(tree2, val2[1], &(val2[1])); + ret = ucx_avl_find(tree2,(intptr_t)11, dist_int, UCX_AVL_FIND_UPPER_BOUNDED); + UCX_TEST_ASSERT(ret && *((int*)ret) == 10, "AVL find LB failed"); + + int val3[] = { 15, 16, 1 }; + ucx_avl_put(tree3, val3[0], &(val3[0])); + ucx_avl_put(tree3, val3[1], &(val3[1])); + ucx_avl_put(tree3, val3[2], &(val3[2])); + + ret = ucx_avl_find(tree3, (intptr_t)13, dist_int, UCX_AVL_FIND_CLOSEST); + UCX_TEST_ASSERT(ret && *((int*)ret) == 15, "AVL find closest failed"); + UCX_TEST_END ucx_avl_free(tree); + ucx_avl_free(tree2); + ucx_avl_free(tree3); } UCX_TEST(test_ucx_avl_traverse) {