Browse Source

Tests: PityTest - Add main header PityTest.hh

Also rename PTASSERT to PITYASSERT
LIB-11
heck 11 months ago
parent
commit
72b36f8f69
9 changed files with 58 additions and 59 deletions
  1. +0
    -21
      test/pitytest11/src/AbstractPityUnit.hh
  2. +33
    -0
      test/pitytest11/src/PityTest.hh
  3. +2
    -4
      test/pitytest11/test/test_execmodes.cc
  4. +1
    -1
      test/pitytest11/test/test_linear.cc
  5. +11
    -11
      test/pitytest11/test/test_processdirs.cc
  6. +2
    -4
      test/pitytest11/test/test_swarm.cc
  7. +3
    -6
      test/test_template_swarm_multi.cc
  8. +3
    -6
      test/test_template_swarm_single.cc
  9. +3
    -6
      test/test_tofu.cc

+ 0
- 21
test/pitytest11/src/AbstractPityUnit.hh View File

@ -115,27 +115,6 @@ namespace pEp {
public:
PityAssertException(const std::string& string) : runtime_error(string) {}
};
#ifndef PTASSERT
#define PTASSERT(condition, msg) \
do { \
if (!(condition)) { \
throw PityAssertException(msg); \
} \
} while (0)
#endif
#ifndef PTASSERT_EXCEPT
#define PTASSERT_EXCEPT(func) \
do { \
try { \
(func); \
PTASSERT(false); \
} catch (const exception& e) { \
} \
} while (0)
#endif
}; // namespace PityTest11
}; // namespace pEp


+ 33
- 0
test/pitytest11/src/PityTest.hh View File

@ -0,0 +1,33 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#ifndef PITYTEST_PITYTEST_HH
#define PITYTEST_PITYTEST_HH
#include "PityUnit.hh"
#include "PityModel.hh"
#include "PitySwarm.hh"
#include "PityPerspective.hh"
#ifndef PITYASSERT
#define PITYASSERT(condition, msg) \
do { \
if (!(condition)) { \
throw PityAssertException(msg); \
} \
} while (0)
#endif
#ifndef PITYASSERT_THROWS
#define PITYASSERT_THROWS(func, msg) \
do { \
try { \
(func); \
PITYASSERT(false, msg); \
} catch (const std::exception& e) { \
} catch (...) { \
} \
} while (0)
#endif
#endif

+ 2
- 4
test/pitytest11/test/test_execmodes.cc View File

@ -1,6 +1,4 @@
#include "../src/PityUnit.hh"
#include "../src/PityModel.hh"
#include "../src/PityPerspective.hh"
#include "../src/PityTest.hh"
#include "../../../src/utils.hh"
#include <iostream>
@ -34,7 +32,7 @@ int main(int argc, char* argv[])
TestUnit::debug_log_enabled = false;
CTXExecmodes ctxe;
ctxe.sleepmilis = 100;
ctxe.rep_count = 3;
ctxe.rep_count = 100;
// Utils::readKey();
// The RootNode is the


+ 1
- 1
test/pitytest11/test/test_linear.cc View File

@ -1,4 +1,4 @@
#include "../src/PityUnit.hh"
#include "../src/PityTest.hh"
#include <iostream>
#include <algorithm>


+ 11
- 11
test/pitytest11/test/test_processdirs.cc View File

@ -1,4 +1,4 @@
#include "../src/PityUnit.hh"
#include "../src/PityTest.hh"
#include <iostream>
#include <algorithm>
@ -20,14 +20,14 @@ int main(int argc, char* argv[])
// 1
PityUnit<> test1 = PityUnit<>{ root, "node 1", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
PITYASSERT(
mynode.processDir() == "./pitytest_data/test_processdirs/",
"");
return 0;
} };
PityUnit<> test1_1 = PityUnit<>{ test1, "node 1.1", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
PITYASSERT(
mynode.processDir() == "./pitytest_data/test_processdirs/",
"");
return 0;
@ -35,7 +35,7 @@ int main(int argc, char* argv[])
// 2
PityUnit<> test2 = PityUnit<>{ root, "node 2", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
PITYASSERT(
mynode.processDir() == "./pitytest_data/test_processdirs/",
"");
return 0;
@ -44,7 +44,7 @@ int main(int argc, char* argv[])
test2,
"node 2.1",
[](PityUnit<>& mynode, void* ctx) {
PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/", "");
PITYASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_2_1/", "");
return 0;
},
nullptr,
@ -53,7 +53,7 @@ int main(int argc, char* argv[])
PityUnit<> test2_1_1 = PityUnit<>{ test2_1, "node 2.1.1", [](PityUnit<> mynode, void* ctx) {
PTASSERT(
PITYASSERT(
mynode.processDir() ==
"./pitytest_data/test_processdirs/node_2_1/",
"");
@ -66,7 +66,7 @@ int main(int argc, char* argv[])
root,
"node 3",
[](PityUnit<>& mynode, void* ctx) {
PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/", "");
PITYASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3/", "");
return 0;
},
nullptr,
@ -74,7 +74,7 @@ int main(int argc, char* argv[])
};
PityUnit<> test3_1 = PityUnit<>{ test3, "node 3.1", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
PITYASSERT(
mynode.processDir() ==
"./pitytest_data/test_processdirs/node_3/",
"");
@ -82,7 +82,7 @@ int main(int argc, char* argv[])
} };
PityUnit<> test3_1_1 = PityUnit<>{ test3_1, "node 3.1.1", [](PityUnit<>& mynode, void* ctx) {
PTASSERT(
PITYASSERT(
mynode.processDir() ==
"./pitytest_data/test_processdirs/node_3/",
"");
@ -93,7 +93,7 @@ int main(int argc, char* argv[])
test3_1_1,
"node 3.1.1",
[](PityUnit<>& mynode, void* ctx) {
PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", "");
PITYASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", "");
return 0;
},
nullptr,
@ -104,7 +104,7 @@ int main(int argc, char* argv[])
test3_1_1_1,
"node 3.1.1.1",
[](PityUnit<>& mynode, void* ctx) {
PTASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", "");
PITYASSERT(mynode.processDir() == "./pitytest_data/test_processdirs/node_3_1_1/", "");
return 0;
}
};


+ 2
- 4
test/pitytest11/test/test_swarm.cc View File

@ -1,7 +1,4 @@
#include "../src/PityUnit.hh"
#include "../src/PityModel.hh"
#include "../src/PitySwarm.hh"
#include "../src/PityPerspective.hh"
#include "../src/PityTest.hh"
using namespace pEp;
using namespace pEp::Adapter;
@ -26,6 +23,7 @@ int test_node1(PityUnit<PityPerspective>& unit, PityPerspective* ctx)
unit.log("MSG RX:" + unit.transport()->receiveMsg());
}
}
return 0;
}
int main(int argc, char* argv[])


+ 3
- 6
test/test_template_swarm_multi.cc View File

@ -1,7 +1,4 @@
#include "pitytest11/src/PityUnit.hh"
#include "pitytest11/src/PityModel.hh"
#include "pitytest11/src/PitySwarm.hh"
#include "pitytest11/src/PityPerspective.hh"
#include "pitytest11/src/PityTest.hh"
#include "../src/utils.hh"
#include "framework/framework.hh"
#include "framework/utils.hh"
@ -33,7 +30,7 @@ int test_func1(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
pity.log("getGlobalRootDir: " +pity.getGlobalRootDir());
pity.log("to_string: " +pity.to_string());
PTASSERT(true,"");
PITYASSERT(true,"");
return 0;
}
@ -41,7 +38,7 @@ int test_func1(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
int test_func2(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
{
pity.log(ctx->own_name);
PTASSERT(false,"");
PITYASSERT(false,"");
return 0;
}


+ 3
- 6
test/test_template_swarm_single.cc View File

@ -1,7 +1,4 @@
#include "pitytest11/src/PityUnit.hh"
#include "pitytest11/src/PityModel.hh"
#include "pitytest11/src/PitySwarm.hh"
#include "pitytest11/src/PityPerspective.hh"
#include "pitytest11/src/PityTest.hh"
#include "../src/utils.hh"
#include "framework/framework.hh"
#include "framework/utils.hh"
@ -32,7 +29,7 @@ int test_func1(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
pity.log("processDir: " + pity.processDir());
pity.log("getGlobalRootDir: " + pity.getGlobalRootDir());
pity.log("to_string: " + pity.to_string(false));
PTASSERT(true,"");
PITYASSERT(true,"");
return 0;
}
@ -40,7 +37,7 @@ int test_func1(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
int test_func2(PityUnit<PityPerspective> &pity, PityPerspective *ctx)
{
pity.log(ctx->own_name);
PTASSERT(false,"");
PITYASSERT(false,"");
return 0;
}


+ 3
- 6
test/test_tofu.cc View File

@ -1,7 +1,4 @@
#include "pitytest11/src/PityUnit.hh"
#include "pitytest11/src/PityModel.hh"
#include "pitytest11/src/PitySwarm.hh"
#include "pitytest11/src/PityPerspective.hh"
#include "pitytest11/src/PityTest.hh"
#include "../src/utils.hh"
#include "framework/framework.hh"
#include "framework/utils.hh"
@ -125,8 +122,8 @@ int tofu(PityUnit<PityPerspective> &pity, PityPerspective *ctx, bool init)
receive(pity, ctx);
}
PTASSERT(did_tx_encrypted, "could never send encrypted");
PTASSERT(did_rx_encrypted, "no encrypted msg received");
PITYASSERT(did_tx_encrypted, "could never send encrypted");
PITYASSERT(did_rx_encrypted, "no encrypted msg received");
return 0;
}


Loading…
Cancel
Save