1.1 --- a/test/test_tree.c Sun Oct 03 13:07:48 2021 +0200 1.2 +++ b/test/test_tree.c Sun Oct 03 14:06:57 2021 +0200 1.3 @@ -60,15 +60,13 @@ 1.4 memset(&c, 0, sizeof(TestNode)); 1.5 1.6 // test 1.7 - int ret = cx_tree_add_node(&a, offsetof(TestNode, parent), offsetof(TestNode, prev), offsetof(TestNode, next), &b); 1.8 - CU_ASSERT_EQUAL(ret, 0) 1.9 + cx_tree_add_sibling(&a, offsetof(TestNode, prev), offsetof(TestNode, next), offsetof(TestNode, parent), &b); 1.10 CU_ASSERT_PTR_EQUAL(b.parent, &root) 1.11 CU_ASSERT_PTR_EQUAL(b.prev, &a) 1.12 CU_ASSERT_PTR_NULL(b.next) 1.13 CU_ASSERT_PTR_EQUAL(a.next, &b) 1.14 - 1.15 - ret = cx_tree_add_node(&a, -1, -1, offsetof(TestNode, next), &c); 1.16 - CU_ASSERT_EQUAL(ret, 0) 1.17 + 1.18 + cx_tree_add_sibling(&a, -1, offsetof(TestNode, next), -1, &c); 1.19 CU_ASSERT_PTR_NULL(c.parent) 1.20 CU_ASSERT_PTR_NULL(c.prev) 1.21 CU_ASSERT_PTR_NULL(c.next) 1.22 @@ -89,63 +87,57 @@ 1.23 TestNode a1; 1.24 memset(&a1, 0, sizeof(TestNode)); 1.25 1.26 - int ret; 1.27 - 1.28 // test 1.29 - ret = cx_tree_add_child_node( 1.30 - &root, 1.31 - offsetof(TestNode, parent), 1.32 + cx_tree_add_child( 1.33 + (void **) &root.children_begin, 1.34 + (void **) &root.children_end, 1.35 offsetof(TestNode, prev), 1.36 offsetof(TestNode, next), 1.37 - (void**)&root.children_begin, 1.38 - (void**)&root.children_end, 1.39 - &a); 1.40 - CU_ASSERT_EQUAL(ret, 0) 1.41 + &a, 1.42 + offsetof(TestNode, parent), 1.43 + &root); 1.44 CU_ASSERT_PTR_EQUAL(root.children_begin, &a) 1.45 CU_ASSERT_PTR_EQUAL(root.children_end, &a) 1.46 CU_ASSERT_PTR_EQUAL(a.parent, &root) 1.47 CU_ASSERT_PTR_NULL(a.prev) 1.48 CU_ASSERT_PTR_NULL(a.next) 1.49 1.50 - ret = cx_tree_add_child_node( 1.51 - &root, 1.52 - offsetof(TestNode, parent), 1.53 + cx_tree_add_child( 1.54 + (void **) &root.children_begin, 1.55 + (void **) &root.children_end, 1.56 offsetof(TestNode, prev), 1.57 offsetof(TestNode, next), 1.58 - (void**)&root.children_begin, 1.59 - (void**)&root.children_end, 1.60 - &b); 1.61 - CU_ASSERT_EQUAL(ret, 0) 1.62 + &b, 1.63 + offsetof(TestNode, parent), 1.64 + &root); 1.65 CU_ASSERT_PTR_NOT_NULL(root.children_begin) 1.66 CU_ASSERT_PTR_EQUAL(root.children_begin->next, &b) 1.67 CU_ASSERT_PTR_EQUAL(root.children_end, &b) 1.68 CU_ASSERT_PTR_EQUAL(b.parent, &root) 1.69 CU_ASSERT_PTR_EQUAL(b.prev, &a) 1.70 - 1.71 - ret = cx_tree_add_child_node( 1.72 - &root, 1.73 - -1, 1.74 + 1.75 + cx_tree_add_child( 1.76 + (void **) &root.children_begin, 1.77 + NULL, 1.78 -1, 1.79 offsetof(TestNode, next), 1.80 - (void**)&root.children_begin, 1.81 - NULL, 1.82 - &c); 1.83 - CU_ASSERT_EQUAL(ret, 0) 1.84 + &c, 1.85 + -1, 1.86 + &root); 1.87 CU_ASSERT_PTR_EQUAL(root.children_end, &b) // children_end unchanged 1.88 CU_ASSERT_PTR_EQUAL(b.next, &c) 1.89 CU_ASSERT_PTR_NULL(c.prev) 1.90 CU_ASSERT_PTR_NULL(c.next) 1.91 CU_ASSERT_PTR_NULL(c.parent) 1.92 - 1.93 - ret = cx_tree_add_child_node( 1.94 - &a, 1.95 - offsetof(TestNode, parent), 1.96 + 1.97 + cx_tree_add_child( 1.98 + (void **) &a.children_begin, 1.99 + (void **) &a.children_end, 1.100 offsetof(TestNode, prev), 1.101 offsetof(TestNode, next), 1.102 - (void**)&a.children_begin, 1.103 - (void**)&a.children_end, 1.104 - &a1); 1.105 - CU_ASSERT_EQUAL(ret, 0); 1.106 + &a1, 1.107 + offsetof(TestNode, parent), 1.108 + &a); 1.109 CU_ASSERT_PTR_EQUAL(a.children_begin, &a1); 1.110 CU_ASSERT_PTR_EQUAL(a1.parent, &a); 1.111 CU_ASSERT_PTR_NOT_NULL(root.children_begin)