49 lines
992 B
C++
49 lines
992 B
C++
#include <iostream>
|
|
#include <memory>
|
|
#include <Tree/tree.hpp>
|
|
|
|
|
|
|
|
int main()
|
|
{
|
|
bool error=false;
|
|
std::shared_ptr<Tree::TreeRoot> t=std::make_shared<Tree::TreeRoot>();
|
|
|
|
// first test if the parent node is a nullptr for root node
|
|
if ( t->getParent() != nullptr )
|
|
{
|
|
std::cerr << "Failed Test: Root node parent is not null" << std::endl;
|
|
error=true;
|
|
}
|
|
|
|
/*
|
|
* create a temp node and add to root
|
|
*/
|
|
std::shared_ptr<Tree::TempNode> temp0=std::make_shared<Tree::TempNode>();
|
|
|
|
t->addChild(temp0);
|
|
|
|
// check if the parent node of temp0 has been set correctly
|
|
if (temp0->getParent() != t)
|
|
{
|
|
std::cerr << "Failed Test: temp0 node parent is null" << std::endl;
|
|
error=true;
|
|
}
|
|
|
|
// check if the number of direct children of t is 1
|
|
if (t->getNrDirectChildren() != 1)
|
|
{
|
|
std::cerr << "Failed Test: nr of direct children is not 1" << std::endl;
|
|
error=true;
|
|
}
|
|
|
|
|
|
if (error)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
std::cerr << "Test OK" << std::endl;
|
|
return 0;
|
|
}
|