diff --git a/test/test_execmodes.cc b/test/test_execmodes.cc index 66758dd..11eff90 100644 --- a/test/test_execmodes.cc +++ b/test/test_execmodes.cc @@ -1,6 +1,7 @@ #include "../src/PityUnit.hh" #include "../src/PityModel.hh" #include "../src/PityPerspective.hh" +#include "../../../src/utils.hh" #include using namespace std; @@ -34,31 +35,56 @@ int main(int argc, char* argv[]) CTXExecmodes ctxe; ctxe.sleepmilis = 100; ctxe.rep_count = 3; + // Utils::readKey(); // The RootNode is the - TestUnit root = TestUnit{ nullptr, "Test Execution Model" }; + TestUnit root = TestUnit{ "Test Execution Model" }; // Subprocess 1 - TestUnit test1 = TestUnit{ &root, + TestUnit test1 = TestUnit{ "node1", do_some_work, &ctxe, TestUnit::ExecutionMode::PROCESS_PARALLEL }; + TestUnit test1_1 = TestUnit{ "test1.1", do_some_work }; + TestUnit test1_2 = TestUnit{ "test1.2", do_some_work }; + + root.add(test1); + test1.add(test1_1); + test1.add(test1_2); + + // Subprocess 2 + TestUnit test2 = TestUnit{ "node2", do_some_work, &ctxe, TestUnit::ExecutionMode::PROCESS_PARALLEL }; + TestUnit test2_1 = TestUnit{ "test2.1", do_some_work }; + TestUnit test2_2 = TestUnit{ "test2.2", do_some_work }; + root.add(test2); + test2.add(test2_1); + test2.add(test2_2); + + root.run(); + + /* +// The RootNode is the + TestUnit root = TestUnit{ "Test Execution Model" }; + + // Subprocess 1 + TestUnit test1 = TestUnit{ root, "node1", do_some_work, &ctxe, TestUnit::ExecutionMode::PROCESS_PARALLEL }; - TestUnit test1_1 = TestUnit{ &test1, "test1.1", do_some_work }; + TestUnit test1_1 = TestUnit{ test1, "test1.1", do_some_work }; - TestUnit test1_2 = TestUnit{ &test1, "test1.2", do_some_work }; + TestUnit test1_2 = TestUnit{ test1, "test1.2", do_some_work }; // Subprocess 2 - TestUnit test2 = TestUnit{ &root, + TestUnit test2 = TestUnit{ root, "node2", do_some_work, &ctxe, TestUnit::ExecutionMode::PROCESS_PARALLEL }; - TestUnit test2_1 = TestUnit{ &test2, "test2.1", do_some_work }; + TestUnit test2_1 = TestUnit{ test2, "test2.1", do_some_work }; - TestUnit test2_2 = TestUnit{ &test2, "test2.2", do_some_work }; + TestUnit test2_2 = TestUnit{ test2, "test2.2", do_some_work }; root.run(); + */ } \ No newline at end of file diff --git a/test/test_linear.cc b/test/test_linear.cc index fe0c7ee..e5ac530 100644 --- a/test/test_linear.cc +++ b/test/test_linear.cc @@ -6,6 +6,8 @@ using namespace std; using namespace pEp; using namespace pEp::PityTest11; +// eeks_test +// The test framework for geeks without the g class Car { private: @@ -53,11 +55,11 @@ int main(int argc, char* argv[]) { // Linear Test CarTestModel model{ "CarTestModel" }; - PityUnit testnode_car{ nullptr, "test car", nullptr, &model }; - PityUnit testnode_setGear{ &testnode_car, "test car setGear()", test_setGear }; - PityUnit testnode_driv{ &testnode_setGear, "test car drive()", &test_drive }; + PityUnit testnode_car{ "test car", nullptr, &model }; + PityUnit testnode_setGear{ testnode_car, "test car setGear()", test_setGear }; + PityUnit testnode_driv{ testnode_setGear, "test car drive()", &test_drive }; - PityUnit testnode_driv_before_gear{ &testnode_car, + PityUnit testnode_driv_before_gear{ testnode_car, "testnode_driv_before_gear", &test_drive }; diff --git a/test/test_processdirs.cc b/test/test_processdirs.cc index c78837d..77aa821 100644 --- a/test/test_processdirs.cc +++ b/test/test_processdirs.cc @@ -16,17 +16,17 @@ void printHomeDir(PityUnit<>& myself) int main(int argc, char* argv[]) { PityUnit<>::debug_log_enabled = false; - PityUnit<> root = PityUnit<>{ nullptr, "test_processdirs" }; + PityUnit<> root = PityUnit<>{ "test_processdirs" }; // 1 - PityUnit<> test1 = PityUnit<>{ &root, "node 1", [](PityUnit<>& mynode, void* ctx) { + PityUnit<> test1 = PityUnit<>{ root, "node 1", [](PityUnit<>& mynode, void* ctx) { PTASSERT( mynode.processDir() == "./pitytest_data/test_processdirs/", ""); return 0; } }; - PityUnit<> test1_1 = PityUnit<>{ &test1, "node 1.1", [](PityUnit<>& mynode, void* ctx) { + PityUnit<> test1_1 = PityUnit<>{ test1, "node 1.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT( mynode.processDir() == "./pitytest_data/test_processdirs/", ""); @@ -34,15 +34,14 @@ int main(int argc, char* argv[]) } }; // 2 - PityUnit<> test2 = PityUnit<>{ &root, "node 2", [](PityUnit<>& mynode, void* ctx) { + PityUnit<> test2 = PityUnit<>{ root, "node 2", [](PityUnit<>& mynode, void* ctx) { PTASSERT( mynode.processDir() == "./pitytest_data/test_processdirs/", ""); return 0; } }; - PityUnit<> test2_1 = PityUnit<>{ - &test2, + test2, "node 2.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/", ""); @@ -53,7 +52,7 @@ int main(int argc, char* argv[]) }; - PityUnit<> test2_1_1 = PityUnit<>{ &test2_1, "node 2.1.1", [](PityUnit<> mynode, void* ctx) { + PityUnit<> test2_1_1 = PityUnit<>{ test2_1, "node 2.1.1", [](PityUnit<> mynode, void* ctx) { PTASSERT( mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/", @@ -64,7 +63,7 @@ int main(int argc, char* argv[]) // 3 PityUnit<> test3 = PityUnit<>{ - &root, + root, "node 3", [](PityUnit<>& mynode, void* ctx) { PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/", ""); @@ -74,7 +73,7 @@ int main(int argc, char* argv[]) PityUnit<>::ExecutionMode::PROCESS_PARALLEL }; - PityUnit<> test3_1 = PityUnit<>{ &test3, "node 3.1", [](PityUnit<>& mynode, void* ctx) { + PityUnit<> test3_1 = PityUnit<>{ test3, "node 3.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT( mynode.processDir() == "./pitytest_data/test_processdirs/node_3/", @@ -82,7 +81,7 @@ int main(int argc, char* argv[]) return 0; } }; - PityUnit<> test3_1_1 = PityUnit<>{ &test3_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) { + PityUnit<> test3_1_1 = PityUnit<>{ test3_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT( mynode.processDir() == "./pitytest_data/test_processdirs/node_3/", @@ -91,7 +90,7 @@ int main(int argc, char* argv[]) } }; PityUnit<> test3_1_1_1 = PityUnit<>{ - &test3_1_1, + test3_1_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", ""); @@ -102,7 +101,7 @@ int main(int argc, char* argv[]) }; PityUnit<> test3_1_1_1_1 = PityUnit<>{ - &test3_1_1_1, + test3_1_1_1, "node 3.1.1.1", [](PityUnit<>& mynode, void* ctx) { PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", ""); diff --git a/test/test_swarm.cc b/test/test_swarm.cc index 2b97c32..9d35bc2 100644 --- a/test/test_swarm.cc +++ b/test/test_swarm.cc @@ -18,7 +18,7 @@ int test_node1(PityUnit& unit, PityPerspective* ctx) int throttle = 1000; while (true) { Utils::sleep_millis(throttle); - for (auto peer : ctx->peers) { + for (const auto& peer : ctx->peers) { unit.transport()->sendMsg(peer, msg); }