add missing details for 100% test coverage in tree.c

Sun, 06 Oct 2024 13:48:00 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 06 Oct 2024 13:48:00 +0200
changeset 916
526ed389c3d2
parent 915
23db9f0c1acd
child 917
ff8ad2c9e1bd

add missing details for 100% test coverage in tree.c

tests/test_tree.c file | annotate | diff | comparison | revisions
--- a/tests/test_tree.c	Sun Oct 06 13:44:26 2024 +0200
+++ b/tests/test_tree.c	Sun Oct 06 13:48:00 2024 +0200
@@ -1922,7 +1922,7 @@
     cx_testing_allocator_destroy(&talloc);
 }
 
-CX_TEST(test_tree_high_remove_root) {
+CX_TEST(test_tree_high_remove_or_destroy_root) {
     CxTestingAllocator talloc;
     cx_testing_allocator_init(&talloc);
     CxAllocator *alloc = &talloc.base;
@@ -1947,6 +1947,9 @@
         CX_TEST_ASSERT(0 != cxTreeRemoveNode(tree, root, NULL));
         CX_TEST_ASSERT(tree->root == root);
         CX_TEST_ASSERT(tree->size == 6);
+        CX_TEST_ASSERT(0 != cxTreeDestroyNode(tree, root, NULL));
+        CX_TEST_ASSERT(tree->root == root);
+        CX_TEST_ASSERT(tree->size == 6);
         cxTreeRemoveSubtree(tree, root);
         CX_TEST_ASSERT(tree->size == 0);
         CX_TEST_ASSERT(tree->root == NULL);
@@ -1956,7 +1959,9 @@
         CxTree *w = cxTreeCreateWrapped(alloc, root, tree_node_file_layout);
         w->advanced_destructor = (cx_destructor_func2) cxFree;
         w->destructor_data = alloc;
-        cxTreeDestroy(w);
+        cxTreeDestroySubtree(w, w->root);
+        CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
+        cxFree(alloc, w);
         CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
     }
     cx_testing_allocator_destroy(&talloc);
@@ -1974,6 +1979,7 @@
     CX_TEST_DO {
         CxTree *tree = cxTreeCreateWrapped(cxDefaultAllocator, &root, tree_node_layout);
         tree->simple_destructor = test_tree_high_simple_destructor_func;
+        cxTreeDestroyNode(tree, &child1, NULL);
         cxTreeDestroy(tree);
         CX_TEST_ASSERT(root.data == 1);
         CX_TEST_ASSERT(child1.data == 1);
@@ -2030,7 +2036,7 @@
     cx_test_register(suite, test_tree_high_insert_many);
     cx_test_register(suite, test_tree_high_add_find_remove_nodes);
     cx_test_register(suite, test_tree_high_add_find_destroy_nodes);
-    cx_test_register(suite, test_tree_high_remove_root);
+    cx_test_register(suite, test_tree_high_remove_or_destroy_root);
     cx_test_register(suite, test_tree_high_simple_destructor);
 
     return suite;

mercurial