tests/test_tree.c

changeset 903
a018f5916d3b
parent 902
5ed7f634f046
child 904
cdc49211d87f
equal deleted inserted replaced
902:5ed7f634f046 903:a018f5916d3b
1605 CX_TEST_ASSERT(tree->loc_last_child == -1); 1605 CX_TEST_ASSERT(tree->loc_last_child == -1);
1606 CX_TEST_ASSERT(tree->loc_prev == offsetof(tree_node, prev)); 1606 CX_TEST_ASSERT(tree->loc_prev == offsetof(tree_node, prev));
1607 CX_TEST_ASSERT(tree->loc_next == offsetof(tree_node, next)); 1607 CX_TEST_ASSERT(tree->loc_next == offsetof(tree_node, next));
1608 cxTreeDestroy(tree); 1608 cxTreeDestroy(tree);
1609 } 1609 }
1610 }
1611
1612 CX_TEST(test_tree_high_subtree_depth) {
1613 tree_node root = {0}, child1 = {0}, child2 = {0}, child3 = {0};
1614 cx_tree_link(&root, &child1, tree_node_layout);
1615 cx_tree_link(&root, &child2, tree_node_layout);
1616 cx_tree_link(&child1, &child3, tree_node_layout);
1617 CxTree *tree = cxTreeCreateWrapped(&root, tree_node_layout);
1618 CX_TEST_DO {
1619 CX_TEST_ASSERT(cxTreeSubtreeDepth(tree, &root) == 3);
1620 CX_TEST_ASSERT(cxTreeSubtreeDepth(tree, &child1) == 2);
1621 CX_TEST_ASSERT(cxTreeSubtreeDepth(tree, &child2) == 1);
1622 CX_TEST_ASSERT(cxTreeSubtreeDepth(tree, &child3) == 1);
1623 }
1624 cxTreeDestroy(tree);
1610 } 1625 }
1611 1626
1612 CxTestSuite *cx_test_suite_tree_low_level(void) { 1627 CxTestSuite *cx_test_suite_tree_low_level(void) {
1613 CxTestSuite *suite = cx_test_suite_new("tree (low level)"); 1628 CxTestSuite *suite = cx_test_suite_new("tree (low level)");
1614 1629
1649 CxTestSuite *suite = cx_test_suite_new("tree (high level)"); 1664 CxTestSuite *suite = cx_test_suite_new("tree (high level)");
1650 1665
1651 cx_test_register(suite, test_tree_high_create); 1666 cx_test_register(suite, test_tree_high_create);
1652 cx_test_register(suite, test_tree_high_create_simple); 1667 cx_test_register(suite, test_tree_high_create_simple);
1653 cx_test_register(suite, test_tree_high_create_wrapped); 1668 cx_test_register(suite, test_tree_high_create_wrapped);
1669 cx_test_register(suite, test_tree_high_subtree_depth);
1654 1670
1655 return suite; 1671 return suite;
1656 } 1672 }

mercurial