26 using namespace gtsam;
50 forest.
roots_.push_back(std::make_shared<TestNode>(0));
51 forest.
roots_.push_back(std::make_shared<TestNode>(1));
52 forest.
roots_[0]->children.push_back(std::make_shared<TestNode>(2));
53 forest.
roots_[0]->children.push_back(std::make_shared<TestNode>(3));
54 forest.
roots_[0]->children[1]->children.push_back(std::make_shared<TestNode>(4));
67 visited.push_back(node->data);
69 const int expectedParentIndex =
70 node->data == 0 ? -1 :
71 node->data == 1 ? -1 :
75 node->data == 10 ? 0 :
76 (parentsMatched =
false, -1);
77 if(expectedParentIndex != parentData)
78 parentsMatched =
false;
88 visited.push_back(node->data);
103 TEST(treeTraversal, DepthFirst)
109 const std::list<int> preOrderExpected{0, 2, 3, 4, 1};
110 const std::list<int> postOrderExpected{2, 4, 3, 0, 1};
132 const std::list<int> preOrder1Expected{0, 2, 3, 4, 1};
133 std::list<int> preOrder1Actual =
getPreorder(testForest1);
134 std::list<int> preOrder2Actual =
getPreorder(testForest2);
139 testForest2.
roots_[0]->children[1]->data = 10;
140 const std::list<int> preOrderModifiedExpected{0, 2, 10, 4, 1};
143 std::list<int> preOrder1ModActual =
getPreorder(testForest1);
144 std::list<int> preOrder2ModActual =
getPreorder(testForest2);
Provides additional testing facilities for common data structures.
FastVector< sharedNode > roots_
TestForest makeTestForest()
static int runAllTests(TestResult &result)
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
std::shared_ptr< TestNode > shared_ptr
void operator()(const TestNode::shared_ptr &node, int myData)
std::list< int > getPreorder(const TestForest &forest)
int operator()(const TestNode::shared_ptr &node, int parentData)
bool assert_container_equality(const std::map< size_t, V2 > &expected, const std::map< size_t, V2 > &actual)
void DepthFirstForest(FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost)
std::vector< shared_ptr > children
#define EXPECT(condition)
FastVector< std::shared_ptr< typename FOREST::Node > > CloneForest(const FOREST &forest)
Node::shared_ptr sharedNode
const FastVector< sharedNode > & roots() const
TEST(SmartFactorBase, Pinhole)