/** exported function implementation section **/ void test_avl_tree(void) { avl_tree_t t_tree = _create_avl_tree(sizeof(int), "int"); avl_tree_t t_tree2 = _create_avl_tree(sizeof(int), "int"); int n_value = 900; _avl_tree_init(&t_tree, NULL, NULL); _avl_tree_insert_equal(&t_tree, &n_value); printf("avl tree1 - size:%u, max_size:%u, empty:%d\n", _avl_tree_size(&t_tree), _avl_tree_max_size(&t_tree), _avl_tree_empty(&t_tree)); /*_avl_tree_init_copy_range(*/ /*&t_tree2, _avl_tree_begin(&t_tree), _avl_tree_begin(&t_tree));*/ /*printf("avl tree2 - size:%u, max_size:%u, empty:%d\n",*/ /*_avl_tree_size(&t_tree2), _avl_tree_max_size(&t_tree2), _avl_tree_empty(&t_tree2));*/ _avl_tree_init_copy_range_cmp( &t_tree2, _avl_tree_begin(&t_tree), _avl_tree_begin(&t_tree), NULL); printf("avl tree2 - size:%u, max_size:%u, empty:%d\n", _avl_tree_size(&t_tree2), _avl_tree_max_size(&t_tree2), _avl_tree_empty(&t_tree2)); _avl_tree_insert_equal_range( &t_tree2, _avl_tree_begin(&t_tree), _avl_tree_begin(&t_tree)); printf("avl tree2 - size:%u, max_size:%u, empty:%d\n", _avl_tree_size(&t_tree2), _avl_tree_max_size(&t_tree2), _avl_tree_empty(&t_tree2)); _avl_tree_insert_unique_range( &t_tree2, _avl_tree_end(&t_tree), _avl_tree_end(&t_tree)); printf("avl tree2 - size:%u, max_size:%u, empty:%d\n", _avl_tree_size(&t_tree2), _avl_tree_max_size(&t_tree2), _avl_tree_empty(&t_tree2)); _avl_tree_erase_range(&t_tree2, _avl_tree_begin(&t_tree2), _avl_tree_begin(&t_tree2)); printf("avl tree2 - size:%u, max_size:%u, empty:%d\n", _avl_tree_size(&t_tree2), _avl_tree_max_size(&t_tree2), _avl_tree_empty(&t_tree2)); _avl_tree_destroy(&t_tree); _avl_tree_destroy(&t_tree2); }
void test__create_avl_tree_auxiliary__libcstl_builtin(void** state) { _avl_tree_t* pt_avl_tree = malloc(sizeof(_avl_tree_t)); assert_true(_create_avl_tree_auxiliary(pt_avl_tree, "vector_t<int>")); assert_true(_avl_tree_is_created(pt_avl_tree)); _avl_tree_destroy(pt_avl_tree); }
void test__create_avl_tree_auxiliary__cstr(void** state) { _avl_tree_t* pt_avl_tree = malloc(sizeof(_avl_tree_t)); assert_true(_create_avl_tree_auxiliary(pt_avl_tree, "char*")); assert_true(_avl_tree_is_created(pt_avl_tree)); _avl_tree_destroy(pt_avl_tree); }
void test__avl_tree_destroy_auxiliary__non_created(void** state) { _avl_tree_t* pt_avl_tree = _create_avl_tree("int"); pt_avl_tree->_t_avlroot._un_height = 9; expect_assert_failure(_avl_tree_destroy_auxiliary(pt_avl_tree)); pt_avl_tree->_t_avlroot._un_height = 0; _avl_tree_destroy(pt_avl_tree); }
/** * Destroy set. */ void set_destroy(set_t* pset_set) { assert(pset_set != NULL); #ifdef CSTL_SET_AVL_TREE _avl_tree_destroy(&pset_set->_t_tree); #else _rb_tree_destroy(&pset_set->_t_tree); #endif }
/** * Destroy multiset. */ void multiset_destroy(multiset_t* pmset_mset) { assert(pmset_mset != NULL); #ifdef CSTL_MULTISET_AVL_TREE _avl_tree_destroy(&pmset_mset->_t_tree); #else _rb_tree_destroy(&pmset_mset->_t_tree); #endif }
void test__create_avl_tree_auxiliary__user_define(void** state) { _avl_tree_t* pt_avl_tree = NULL; type_register(_test__create_avl_tree_auxiliary__user_define_t, NULL, NULL, NULL, NULL); pt_avl_tree = malloc(sizeof(_avl_tree_t)); assert_true(_create_avl_tree_auxiliary(pt_avl_tree, "_test__create_avl_tree_auxiliary__user_define_t")); assert_true(_avl_tree_is_created(pt_avl_tree)); _avl_tree_destroy(pt_avl_tree); }
void multimap_destroy(multimap_t* pt_multimap) { assert(pt_multimap != NULL); /* destroy pair */ pair_destroy(&pt_multimap->_t_pair); /* destroy tree */ #ifdef CSTL_MULTIMAP_AVL_TREE _avl_tree_destroy(_GET_MULTIMAP_AVL_TREE(pt_multimap)); #else _rb_tree_destroy(_GET_MULTIMAP_RB_TREE(pt_multimap)); #endif }