• R/O
  • SSH
  • HTTPS

bchan: 提交


Commit MetaInfo

修訂645 (tree)
時間2014-11-28 23:44:10
作者ornse01

Log Message

add test case.

Change Summary

差異

--- bchanf/trunk/src/coll/test_treebase.c (revision 644)
+++ bchanf/trunk/src/coll/test_treebase.c (revision 645)
@@ -537,7 +537,47 @@
537537 return ret;
538538 }
539539
540+LOCAL UNITTEST_RESULT test_treebase_preordertraversal_2()
541+{
542+ treebase_node_t node0, node1, node2, node3, node4;
543+ test_treebase_preordertraversal_expected_t expected[] = {
544+ { True, &node0, TREEBASE_TRAVERSAL_DIRECTION_DOWN },
545+ { True, &node1, TREEBASE_TRAVERSAL_DIRECTION_DOWN },
546+ { True, &node2, TREEBASE_TRAVERSAL_DIRECTION_DOWN },
547+ { True, &node3, TREEBASE_TRAVERSAL_DIRECTION_DOWN },
548+ { True, &node3, TREEBASE_TRAVERSAL_DIRECTION_UP },
549+ { True, &node4, TREEBASE_TRAVERSAL_DIRECTION_DOWN },
550+ { True, &node4, TREEBASE_TRAVERSAL_DIRECTION_UP },
551+ { True, &node2, TREEBASE_TRAVERSAL_DIRECTION_UP },
552+ { True, &node1, TREEBASE_TRAVERSAL_DIRECTION_UP },
553+ { True, &node0, TREEBASE_TRAVERSAL_DIRECTION_UP },
554+ };
555+ W expected_len = sizeof(expected) / sizeof(test_treebase_preordertraversal_expected_t);
556+ UNITTEST_RESULT ret;
540557
558+ treebase_node_initialize(&node0);
559+ treebase_node_initialize(&node1);
560+ treebase_node_initialize(&node2);
561+ treebase_node_initialize(&node3);
562+ treebase_node_initialize(&node4);
563+
564+ treebase_node_appendchild(&node0, &node1);
565+ treebase_node_appendchild(&node1, &node2);
566+ treebase_node_appendchild(&node2, &node3);
567+ treebase_node_appendchild(&node2, &node4);
568+
569+ ret = test_treebase_preordertraversal_common(&node0, expected, expected_len);
570+
571+ treebase_node_finalize(&node4);
572+ treebase_node_finalize(&node3);
573+ treebase_node_finalize(&node2);
574+ treebase_node_finalize(&node1);
575+ treebase_node_finalize(&node0);
576+
577+ return ret;
578+}
579+
580+
541581 EXPORT VOID test_treebase_main(unittest_driver_t *driver)
542582 {
543583 UNITTEST_DRIVER_REGIST(driver, test_treebase_node_1);
@@ -549,4 +589,5 @@
549589 UNITTEST_DRIVER_REGIST(driver, test_treebase_node_7);
550590 UNITTEST_DRIVER_REGIST(driver, test_treebase_node_8);
551591 UNITTEST_DRIVER_REGIST(driver, test_treebase_preordertraversal_1);
592+ UNITTEST_DRIVER_REGIST(driver, test_treebase_preordertraversal_2);
552593 }
Show on old repository browser