From 5a4823df4f3ead642e4a6e84a972db5ed61a075a Mon Sep 17 00:00:00 2001 From: Sebastian Poeplau Date: Wed, 25 Jul 2018 14:56:39 +0200 Subject: Fix PTree::remove to clean the tree properly The previous version left unnecessary intermediate nodes behind, sometimes leading to very long paths in the tree. --- unittests/Searcher/SearcherTest.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'unittests/Searcher') diff --git a/unittests/Searcher/SearcherTest.cpp b/unittests/Searcher/SearcherTest.cpp index fdd93e62..eff5a8af 100644 --- a/unittests/Searcher/SearcherTest.cpp +++ b/unittests/Searcher/SearcherTest.cpp @@ -51,13 +51,13 @@ TEST(SearcherTest, RandomPath) { } rp.update(&es, {&es1}, {&es}); - PTree::remove(es.ptreeNode); + processTree.remove(es.ptreeNode); for (int i = 0; i < 100; i++) { EXPECT_EQ(&rp.selectState(), &es1); } rp.update(&es1, {}, {&es1}); - PTree::remove(es1.ptreeNode); + processTree.remove(es1.ptreeNode); EXPECT_TRUE(rp.empty()); } @@ -103,16 +103,16 @@ TEST(SearcherTest, TwoRandomPath) { } rp1.update(&es, {}, {&es}); - PTree::remove(es.ptreeNode); + processTree.remove(es.ptreeNode); EXPECT_TRUE(rp1.empty()); EXPECT_EQ(&rp.selectState(), &es1); rp.update(&es1, {}, {&es1}); - PTree::remove(es1.ptreeNode); + processTree.remove(es1.ptreeNode); EXPECT_TRUE(rp.empty()); EXPECT_TRUE(rp1.empty()); - PTree::remove(root.ptreeNode); + processTree.remove(root.ptreeNode); } TEST(SearcherTest, TwoRandomPathDot) { @@ -174,7 +174,7 @@ TEST(SearcherTest, TwoRandomPathDot) { rp1.update(nullptr, {&es}, {&es1}); rp1.update(&es, {}, {&es}); - PTree::remove(es.ptreeNode); + processTree.remove(es.ptreeNode); modelPTreeDot.str(""); modelPTreeDot @@ -198,15 +198,15 @@ TEST(SearcherTest, TwoRandomPathDot) { pTreeDot = ""; processTree.dump(pTreeDotStream); EXPECT_EQ(modelPTreeDot.str(), pTreeDotStream.str()); - PTree::remove(es1.ptreeNode); - PTree::remove(root.ptreeNode); + processTree.remove(es1.ptreeNode); + processTree.remove(root.ptreeNode); } TEST(SearcherDeathTest, TooManyRandomPaths) { // First state ExecutionState es; PTree processTree(&es); es.ptreeNode = processTree.root.getPointer(); - PTree::remove(es.ptreeNode); // Need to remove to avoid leaks + processTree.remove(es.ptreeNode); // Need to remove to avoid leaks RNG rng; RandomPathSearcher rp(processTree, rng); -- cgit 1.4.1