add missing cxTreeVisitorDispose() test

Wed, 20 Mar 2024 23:35:32 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 20 Mar 2024 23:35:32 +0100
changeset 847
a39e410a05e6
parent 846
71f4e0a13bb0
child 848
6456036bbb37

add missing cxTreeVisitorDispose() test

tests/test_tree.c file | annotate | diff | comparison | revisions
--- a/tests/test_tree.c	Wed Mar 20 23:35:18 2024 +0100
+++ b/tests/test_tree.c	Wed Mar 20 23:35:32 2024 +0100
@@ -509,6 +509,27 @@
     cx_testing_allocator_destroy(&talloc);
 }
 
+CX_TEST(test_tree_visitor_create_and_dispose) {
+    tree_node root;
+    tree_node child;
+    cx_tree_link(&root, &child, tree_node_layout);
+    CX_TEST_DO {
+        CxTreeVisitor iter = cx_tree_visitor(&root, tree_child_list);
+        CX_TEST_ASSERT(iter.counter == 1);
+        CX_TEST_ASSERT(iter.node == &root);
+        CX_TEST_ASSERT(!iter.base.mutating);
+        CX_TEST_ASSERT(!iter.base.remove);
+        CX_TEST_ASSERT(iter.queue_next != NULL);
+        CX_TEST_ASSERT(iter.queue_last != NULL);
+        CX_TEST_ASSERT(iter.depth == 1);
+        CX_TEST_ASSERT(iter.loc_next == offsetof(tree_node, next));
+        CX_TEST_ASSERT(iter.loc_children == offsetof(tree_node, children));
+        cxTreeVisitorDispose(&iter);
+        CX_TEST_ASSERT(iter.queue_next == NULL);
+        CX_TEST_ASSERT(iter.queue_last == NULL);
+    }
+}
+
 CX_TEST(test_tree_visitor) {
     tree_node root = {0};
     tree_node a = {0};

mercurial