• R/O
  • HTTP
  • SSH
  • HTTPS

bchanf: Commit

各種ライブラリ


Commit MetaInfo

Revision61a54cc7594d89d6e9d55ec9358fe873de47230c (tree)
Time2014-11-22 02:36:26
Authorornse01 <ornse01@user...>
Commiterornse01

Log Message

fix bug updating first child in insertbefore.

git-svn-id: http://svn.sourceforge.jp/svnroot/bchan/bchanf/trunk@643 20a0b8eb-f62a-4a12-8fe1-b598822500fb

Change Summary

Incremental Difference

--- a/src/coll/test_treebase.c
+++ b/src/coll/test_treebase.c
@@ -378,6 +378,75 @@ LOCAL UNITTEST_RESULT test_treebase_node_7()
378378 return ret;
379379 }
380380
381+LOCAL UNITTEST_RESULT test_treebase_node_8()
382+{
383+ treebase_node_t node0, node1, node2, node3;
384+ test_treebase_node_expected_t expected;
385+ Bool ok;
386+ UNITTEST_RESULT ret = UNITTEST_RESULT_PASS;
387+
388+ treebase_node_initialize(&node0);
389+ treebase_node_initialize(&node1);
390+ treebase_node_initialize(&node2);
391+ treebase_node_initialize(&node3);
392+
393+ treebase_node_insertbefore(&node0, &node1, NULL);
394+ treebase_node_insertbefore(&node0, &node2, &node1);
395+ treebase_node_insertbefore(&node0, &node3, NULL);
396+
397+ /**/
398+ expected.parent = NULL;
399+ expected.next = NULL;
400+ expected.prev = NULL;
401+ expected.first = &node2;
402+ expected.last = &node3;
403+ expected.has_child = True;
404+ ok = test_treebase_node_commoncheck(&node0, &expected, "node0");
405+ if (ok == False) {
406+ ret = UNITTEST_RESULT_FAIL;
407+ }
408+ /**/
409+ expected.parent = &node0;
410+ expected.next = &node3;
411+ expected.prev = &node2;
412+ expected.first = NULL;
413+ expected.last = NULL;
414+ expected.has_child = False;
415+ ok = test_treebase_node_commoncheck(&node1, &expected, "node1");
416+ if (ok == False) {
417+ ret = UNITTEST_RESULT_FAIL;
418+ }
419+ /**/
420+ expected.parent = &node0;
421+ expected.next = &node1;
422+ expected.prev = NULL;
423+ expected.first = NULL;
424+ expected.last = NULL;
425+ expected.has_child = False;
426+ ok = test_treebase_node_commoncheck(&node2, &expected, "node2");
427+ if (ok == False) {
428+ ret = UNITTEST_RESULT_FAIL;
429+ }
430+ /**/
431+ expected.parent = &node0;
432+ expected.next = NULL;
433+ expected.prev = &node1;
434+ expected.first = NULL;
435+ expected.last = NULL;
436+ expected.has_child = False;
437+ ok = test_treebase_node_commoncheck(&node3, &expected, "node3");
438+ if (ok == False) {
439+ ret = UNITTEST_RESULT_FAIL;
440+ }
441+
442+ treebase_node_finalize(&node3);
443+ treebase_node_finalize(&node2);
444+ treebase_node_finalize(&node1);
445+ treebase_node_finalize(&node0);
446+
447+ return ret;
448+}
449+
381450 /* treebase_preordertraversal_t */
382451
383452 typedef struct {
@@ -478,5 +547,6 @@ EXPORT VOID test_treebase_main(unittest_driver_t *driver)
478547 UNITTEST_DRIVER_REGIST(driver, test_treebase_node_5);
479548 UNITTEST_DRIVER_REGIST(driver, test_treebase_node_6);
480549 UNITTEST_DRIVER_REGIST(driver, test_treebase_node_7);
550+ UNITTEST_DRIVER_REGIST(driver, test_treebase_node_8);
481551 UNITTEST_DRIVER_REGIST(driver, test_treebase_preordertraversal_1);
482552 }
--- a/src/coll/treebase.c
+++ b/src/coll/treebase.c
@@ -53,6 +53,9 @@ EXPORT W treebase_node_insertbefore(treebase_node_t *node, treebase_node_t *chil
5353 return -1; /* TODO */
5454 }
5555
56+ if (node->firstchild == ref) {
57+ node->firstchild = child;
58+ }
5659 QueInsert(&child->sibling, &ref->sibling);
5760 child->parent = node;
5861
Show on old repository browser