Browse Source

Tests: update for pointers instead of refs.

master
heck 4 years ago
parent
commit
82bdee4eff
  1. 8
      test/test_execmodes.cc
  2. 30
      test/test_pitytree.cc
  3. 16
      test/test_processdirs.cc

8
test/test_execmodes.cc

@ -53,12 +53,12 @@ int main(int argc, char* argv[])
TestUnit::ExecutionMode::PROCESS_PARALLEL);
// Units
grp1.addNew<TestUnit>("test1.1", do_some_work);
grp1.addNew<TestUnit>("test1.2", do_some_work);
grp1->addNew<TestUnit>("test1.1", do_some_work);
grp1->addNew<TestUnit>("test1.2", do_some_work);
// Units
grp2.addNew<TestUnit>("unit_2.1", do_some_work);
grp2.addNew<TestUnit>("unit_2.2", do_some_work);
grp2->addNew<TestUnit>("unit_2.1", do_some_work);
grp2->addNew<TestUnit>("unit_2.2", do_some_work);
suite.run();
}

30
test/test_pitytree.cc

@ -19,7 +19,7 @@ public:
// methods
virtual int implMe(int magic_nr) = 0;
AbstractNode& getSelf() override = 0;
AbstractNode *getSelf() override = 0;
AbstractNode *clone() override = 0;
// fields
@ -49,7 +49,7 @@ public:
explicit ANode(const std::string &name);
explicit ANode(const std::string &name, AbstractNode &parent);
ANode(const ANode &rhs);
ANode &getSelf() override;
ANode *getSelf() override;
ANode *clone() override;
int implMe(int magic_nr) override;
};
@ -63,9 +63,9 @@ int ANode::implMe(int magic_nr)
return 23;
}
ANode &ANode::getSelf()
ANode *ANode::getSelf()
{
return *this;
return this;
}
ANode *ANode::clone()
@ -80,7 +80,7 @@ public:
explicit BNode(const std::string &name);
explicit BNode(const std::string &name, AbstractNode &parent);
BNode(const BNode &rhs);
BNode &getSelf() override;
BNode *getSelf() override;
BNode *clone() override;
int implMe(int magic_nr) override;
};
@ -94,9 +94,9 @@ int BNode::implMe(int magic_nr)
return 42;
}
BNode &BNode::getSelf()
BNode *BNode::getSelf()
{
return *this;
return this;
}
BNode *BNode::clone()
@ -113,7 +113,7 @@ int main(int argc, char *argv[])
std::cout << a.getPath() << std::endl;
PITYASSERT(a.isRoot() == true, "a");
PITYASSERT(a.getName() == "a", "b");
PITYASSERT(&(a.getRoot()) == &a, "c");
PITYASSERT(a.getRoot() == &a, "c");
PITYASSERT(a.getParent() == nullptr, "d");
PITYASSERT(a.getChildRefs().size() == 0, "e");
@ -121,28 +121,28 @@ int main(int argc, char *argv[])
BNode b{ "b", a };
std::cout << b.getPath() << std::endl;
PITYASSERT(a.isRoot() == true, "f");
PITYASSERT(&(a.getRoot()) == &a, "g");
PITYASSERT(a.getRoot() == &a, "g");
PITYASSERT(a.getParent() == nullptr, "1");
PITYASSERT(a.getChildRefs().size() == 1, "2");
PITYASSERT(&b == &(a.getChild("b")), "3");
PITYASSERT(&b == a.getChild("b"), "3");
PITYASSERT_THROWS(a.getChild("invalid"), "4");
PITYASSERT(b.isRoot() == false, "5");
PITYASSERT(&(b.getRoot()) == &a, "6");
PITYASSERT(b.getRoot() == &a, "6");
PITYASSERT(b.getParent() == &a, "7");
PITYASSERT(b.getChildRefs().size() == 0, "8");
// Create a copy of the node in the parent node
b.addNew<ANode>("c").addNew<ANode>("d");
b.addNew<ANode>("c")->addNew<ANode>("d");
std::cout << a.to_string() << std::endl;
b.addNew<BNode>("c1").addNew<BNode>("e");
b.addNew<BNode>("c1")->addNew<BNode>("e");
std::cout << a.to_string() << std::endl;
b.getChild("c1").getChild("e").addCopy(ANode(a), "a1");
b.getChild("c1")->getChild("e")->addCopy(ANode(a), "a1");
std::cout << a.to_string() << std::endl;
a.getChild("b").addCopy(ANode(a), a.getName() + "1");
a.getChild("b")->addCopy(ANode(a), a.getName() + "1");
std::cout << a.to_string() << std::endl;
ANode a2 = ANode(a);

16
test/test_processdirs.cc

@ -32,7 +32,7 @@ int main(int argc, char* argv[])
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/", "node 1");
return 0;
})
.addNew<TestUnit>("node 1.1", [](TestUnit& pity, TestContext* ctx) {
->addNew<TestUnit>("node 1.1", [](TestUnit& pity, TestContext* ctx) {
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/", "node 1.1");
return 0;
});
@ -45,7 +45,7 @@ int main(int argc, char* argv[])
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/", "node 2");
return 0;
})
.addNew<TestUnit>(
->addNew<TestUnit>(
"node 2.1",
[](TestUnit& pity, TestContext* ctx) {
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/node_2_1/", "");
@ -53,7 +53,7 @@ int main(int argc, char* argv[])
},
nullptr,
PityUnit<>::ExecutionMode::PROCESS_PARALLEL)
.addNew<TestUnit>("node 2.1.1", [](TestUnit& pity, TestContext* ctx) {
->addNew<TestUnit>("node 2.1.1", [](TestUnit& pity, TestContext* ctx) {
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/node_2_1/", "");
return 0;
});
@ -69,19 +69,19 @@ int main(int argc, char* argv[])
},
nullptr,
PityUnit<>::ExecutionMode::PROCESS_PARALLEL)
.addNew<TestUnit>(
->addNew<TestUnit>(
"node 3.1",
[](TestUnit& pity, TestContext* ctx) {
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/node_3/", "");
return 0;
})
.addNew<TestUnit>(
->addNew<TestUnit>(
"node 3.1.1",
[](TestUnit& pity, TestContext* ctx) {
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/node_3/", "");
return 0;
})
.addNew<TestUnit>(
->addNew<TestUnit>(
"node 3.1.1",
[](TestUnit& pity, TestContext* ctx) {
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/node_3_1_1/", "");
@ -89,10 +89,10 @@ int main(int argc, char* argv[])
},
nullptr,
PityUnit<>::ExecutionMode::PROCESS_PARALLEL)
.addNew<TestUnit>("node 3.1.1.1", [](TestUnit& pity, TestContext* ctx) {
->addNew<TestUnit>("node 3.1.1.1", [](TestUnit& pity, TestContext* ctx) {
PITYASSERT(pity.getProcessDir() == "./pitytest_data/test_processdirs/node_3_1_1/", "");
return 0;
});
suite.run();
}
}

Loading…
Cancel
Save