From 4a7b4b0a8d41968c0cc012466749c33501ad485a Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 7 Apr 2013 01:33:29 +0200 Subject: [PATCH] WIP reshape test fixture to get a better call structure This test setup is intended to emulate the situation when adding jobs to the scheduler; thus we should use an implicit sequence as root element. I.e. we have to treat a wood, not a single tree Note: test still fails, since we take a copy of a Node object somewhere inadvertently --- .../hierarchy-orientation-indicator-test.cpp | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/tests/library/hierarchy-orientation-indicator-test.cpp b/tests/library/hierarchy-orientation-indicator-test.cpp index 4703ece25..3b4d4f76a 100644 --- a/tests/library/hierarchy-orientation-indicator-test.cpp +++ b/tests/library/hierarchy-orientation-indicator-test.cpp @@ -56,13 +56,12 @@ namespace test { // using std::vector; using std::tr1::ref; using std::tr1::function; - using iter_stl::eachElm; using lib::IterStateWrapper; using lib::transformIterator; const uint MAX_ID(100); const uint MAX_CHILDREN(5); - const double CHILD_PROBABILITY(0.02); + const double CHILD_PROBABILITY(0.06); const uint CHILDREN_TOTAL_LIMIT(20); const uint CHILDREN_SEED(20); @@ -84,7 +83,7 @@ namespace test { ++random_children_created; int cnt = (rand() % limit) - bottom; - if (random_children_created > CHILDREN_TOTAL_LIMIT) cnt=0; +// if (random_children_created > CHILDREN_TOTAL_LIMIT) cnt=0; if (0 < MAX (0, cnt)) cout << "Kau: "<< cnt <= path_.size()) { // add first node at begin of tree visitation + path_.clear(); path_.push_back(nextNode); - return +1; + return 0; // by convention, here the root is an implicitly pre-existing context } throw error::Logic("corrupted test data tree or tree visitation floundered"); } @@ -252,12 +256,11 @@ namespace test { struct TreeRebuilder + : Node { - Node tree; - template TreeRebuilder (IT treeTraversal) - : tree(0,0) + : Node(0) { populate (transformIterator (treeTraversal, function(NodeVisitor()))); @@ -328,7 +331,7 @@ namespace test { }; - Builder builder(this->tree); + Builder builder(*this); // pre-existing implicit root context builder.populateBy (treeVisitation); } @@ -363,14 +366,17 @@ namespace test { */ void demonstrate_tree_rebuilding ( ) { - Node testTree (-1, CHILDREN_SEED); - cout << "testing with a tree of size="<>= exploreChildren); + using iter_stl::eachElm; + - CHECK (reconstructed.tree == testTree); + TreeRebuilder reconstructed (depthFirst (eachElm (testWood)) >>= exploreChildren); + + cout << reconstructed.children_.size() << "=?=" << testWood.size(); + CHECK (reconstructed.children_ == testWood); } };