diff -r a10c3e127050 -r bb144d08cd44 test/test_tree.c --- a/test/test_tree.c Sun Oct 03 13:07:48 2021 +0200 +++ b/test/test_tree.c Sun Oct 03 14:06:57 2021 +0200 @@ -60,15 +60,13 @@ memset(&c, 0, sizeof(TestNode)); // test - int ret = cx_tree_add_node(&a, offsetof(TestNode, parent), offsetof(TestNode, prev), offsetof(TestNode, next), &b); - CU_ASSERT_EQUAL(ret, 0) + cx_tree_add_sibling(&a, offsetof(TestNode, prev), offsetof(TestNode, next), offsetof(TestNode, parent), &b); CU_ASSERT_PTR_EQUAL(b.parent, &root) CU_ASSERT_PTR_EQUAL(b.prev, &a) CU_ASSERT_PTR_NULL(b.next) CU_ASSERT_PTR_EQUAL(a.next, &b) - - ret = cx_tree_add_node(&a, -1, -1, offsetof(TestNode, next), &c); - CU_ASSERT_EQUAL(ret, 0) + + cx_tree_add_sibling(&a, -1, offsetof(TestNode, next), -1, &c); CU_ASSERT_PTR_NULL(c.parent) CU_ASSERT_PTR_NULL(c.prev) CU_ASSERT_PTR_NULL(c.next) @@ -89,63 +87,57 @@ TestNode a1; memset(&a1, 0, sizeof(TestNode)); - int ret; - // test - ret = cx_tree_add_child_node( - &root, - offsetof(TestNode, parent), + cx_tree_add_child( + (void **) &root.children_begin, + (void **) &root.children_end, offsetof(TestNode, prev), offsetof(TestNode, next), - (void**)&root.children_begin, - (void**)&root.children_end, - &a); - CU_ASSERT_EQUAL(ret, 0) + &a, + offsetof(TestNode, parent), + &root); CU_ASSERT_PTR_EQUAL(root.children_begin, &a) CU_ASSERT_PTR_EQUAL(root.children_end, &a) CU_ASSERT_PTR_EQUAL(a.parent, &root) CU_ASSERT_PTR_NULL(a.prev) CU_ASSERT_PTR_NULL(a.next) - ret = cx_tree_add_child_node( - &root, - offsetof(TestNode, parent), + cx_tree_add_child( + (void **) &root.children_begin, + (void **) &root.children_end, offsetof(TestNode, prev), offsetof(TestNode, next), - (void**)&root.children_begin, - (void**)&root.children_end, - &b); - CU_ASSERT_EQUAL(ret, 0) + &b, + offsetof(TestNode, parent), + &root); CU_ASSERT_PTR_NOT_NULL(root.children_begin) CU_ASSERT_PTR_EQUAL(root.children_begin->next, &b) CU_ASSERT_PTR_EQUAL(root.children_end, &b) CU_ASSERT_PTR_EQUAL(b.parent, &root) CU_ASSERT_PTR_EQUAL(b.prev, &a) - - ret = cx_tree_add_child_node( - &root, - -1, + + cx_tree_add_child( + (void **) &root.children_begin, + NULL, -1, offsetof(TestNode, next), - (void**)&root.children_begin, - NULL, - &c); - CU_ASSERT_EQUAL(ret, 0) + &c, + -1, + &root); CU_ASSERT_PTR_EQUAL(root.children_end, &b) // children_end unchanged CU_ASSERT_PTR_EQUAL(b.next, &c) CU_ASSERT_PTR_NULL(c.prev) CU_ASSERT_PTR_NULL(c.next) CU_ASSERT_PTR_NULL(c.parent) - - ret = cx_tree_add_child_node( - &a, - offsetof(TestNode, parent), + + cx_tree_add_child( + (void **) &a.children_begin, + (void **) &a.children_end, offsetof(TestNode, prev), offsetof(TestNode, next), - (void**)&a.children_begin, - (void**)&a.children_end, - &a1); - CU_ASSERT_EQUAL(ret, 0); + &a1, + offsetof(TestNode, parent), + &a); CU_ASSERT_PTR_EQUAL(a.children_begin, &a1); CU_ASSERT_PTR_EQUAL(a1.parent, &a); CU_ASSERT_PTR_NOT_NULL(root.children_begin)