1920 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
1920 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
1921 } |
1921 } |
1922 cx_testing_allocator_destroy(&talloc); |
1922 cx_testing_allocator_destroy(&talloc); |
1923 } |
1923 } |
1924 |
1924 |
1925 CX_TEST(test_tree_high_remove_root) { |
1925 CX_TEST(test_tree_high_remove_or_destroy_root) { |
1926 CxTestingAllocator talloc; |
1926 CxTestingAllocator talloc; |
1927 cx_testing_allocator_init(&talloc); |
1927 cx_testing_allocator_init(&talloc); |
1928 CxAllocator *alloc = &talloc.base; |
1928 CxAllocator *alloc = &talloc.base; |
1929 |
1929 |
1930 CX_TEST_DO { |
1930 CX_TEST_DO { |
1945 cxTreeInsertArray(tree, paths, sizeof(const char*), 6); |
1945 cxTreeInsertArray(tree, paths, sizeof(const char*), 6); |
1946 void *root = tree->root; |
1946 void *root = tree->root; |
1947 CX_TEST_ASSERT(0 != cxTreeRemoveNode(tree, root, NULL)); |
1947 CX_TEST_ASSERT(0 != cxTreeRemoveNode(tree, root, NULL)); |
1948 CX_TEST_ASSERT(tree->root == root); |
1948 CX_TEST_ASSERT(tree->root == root); |
1949 CX_TEST_ASSERT(tree->size == 6); |
1949 CX_TEST_ASSERT(tree->size == 6); |
|
1950 CX_TEST_ASSERT(0 != cxTreeDestroyNode(tree, root, NULL)); |
|
1951 CX_TEST_ASSERT(tree->root == root); |
|
1952 CX_TEST_ASSERT(tree->size == 6); |
1950 cxTreeRemoveSubtree(tree, root); |
1953 cxTreeRemoveSubtree(tree, root); |
1951 CX_TEST_ASSERT(tree->size == 0); |
1954 CX_TEST_ASSERT(tree->size == 0); |
1952 CX_TEST_ASSERT(tree->root == NULL); |
1955 CX_TEST_ASSERT(tree->root == NULL); |
1953 CX_TEST_ASSERT(cxTreeDepth(tree) == 0); |
1956 CX_TEST_ASSERT(cxTreeDepth(tree) == 0); |
1954 cxTreeDestroy(tree); |
1957 cxTreeDestroy(tree); |
1955 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); |
1958 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); |
1956 CxTree *w = cxTreeCreateWrapped(alloc, root, tree_node_file_layout); |
1959 CxTree *w = cxTreeCreateWrapped(alloc, root, tree_node_file_layout); |
1957 w->advanced_destructor = (cx_destructor_func2) cxFree; |
1960 w->advanced_destructor = (cx_destructor_func2) cxFree; |
1958 w->destructor_data = alloc; |
1961 w->destructor_data = alloc; |
1959 cxTreeDestroy(w); |
1962 cxTreeDestroySubtree(w, w->root); |
|
1963 CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc)); |
|
1964 cxFree(alloc, w); |
1960 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
1965 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
1961 } |
1966 } |
1962 cx_testing_allocator_destroy(&talloc); |
1967 cx_testing_allocator_destroy(&talloc); |
1963 } |
1968 } |
1964 |
1969 |
1972 cx_tree_link(&root, &child2, tree_node_layout); |
1977 cx_tree_link(&root, &child2, tree_node_layout); |
1973 cx_tree_link(&child1, &child3, tree_node_layout); |
1978 cx_tree_link(&child1, &child3, tree_node_layout); |
1974 CX_TEST_DO { |
1979 CX_TEST_DO { |
1975 CxTree *tree = cxTreeCreateWrapped(cxDefaultAllocator, &root, tree_node_layout); |
1980 CxTree *tree = cxTreeCreateWrapped(cxDefaultAllocator, &root, tree_node_layout); |
1976 tree->simple_destructor = test_tree_high_simple_destructor_func; |
1981 tree->simple_destructor = test_tree_high_simple_destructor_func; |
|
1982 cxTreeDestroyNode(tree, &child1, NULL); |
1977 cxTreeDestroy(tree); |
1983 cxTreeDestroy(tree); |
1978 CX_TEST_ASSERT(root.data == 1); |
1984 CX_TEST_ASSERT(root.data == 1); |
1979 CX_TEST_ASSERT(child1.data == 1); |
1985 CX_TEST_ASSERT(child1.data == 1); |
1980 CX_TEST_ASSERT(child2.data == 1); |
1986 CX_TEST_ASSERT(child2.data == 1); |
1981 CX_TEST_ASSERT(child3.data == 1); |
1987 CX_TEST_ASSERT(child3.data == 1); |
2028 cx_test_register(suite, test_tree_high_tree_depth); |
2034 cx_test_register(suite, test_tree_high_tree_depth); |
2029 cx_test_register(suite, test_tree_high_insert_one); |
2035 cx_test_register(suite, test_tree_high_insert_one); |
2030 cx_test_register(suite, test_tree_high_insert_many); |
2036 cx_test_register(suite, test_tree_high_insert_many); |
2031 cx_test_register(suite, test_tree_high_add_find_remove_nodes); |
2037 cx_test_register(suite, test_tree_high_add_find_remove_nodes); |
2032 cx_test_register(suite, test_tree_high_add_find_destroy_nodes); |
2038 cx_test_register(suite, test_tree_high_add_find_destroy_nodes); |
2033 cx_test_register(suite, test_tree_high_remove_root); |
2039 cx_test_register(suite, test_tree_high_remove_or_destroy_root); |
2034 cx_test_register(suite, test_tree_high_simple_destructor); |
2040 cx_test_register(suite, test_tree_high_simple_destructor); |
2035 |
2041 |
2036 return suite; |
2042 return suite; |
2037 } |
2043 } |