|
|
|
@ -27,10 +27,10 @@ namespace pEp {
|
|
|
|
|
PityUnit<TestContext>::PityUnit(
|
|
|
|
|
const std::string &name,
|
|
|
|
|
TestFunction test_func,
|
|
|
|
|
TestContext *perspective,
|
|
|
|
|
TestContext *ctx,
|
|
|
|
|
ExecutionMode exec_mode) :
|
|
|
|
|
AbstractPityUnit(name, exec_mode),
|
|
|
|
|
_perspective{ perspective }, _test_func{ test_func }
|
|
|
|
|
_ctx{ ctx }, _test_func{ test_func }
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -39,10 +39,10 @@ namespace pEp {
|
|
|
|
|
AbstractPityUnit &parent,
|
|
|
|
|
const std::string &name,
|
|
|
|
|
TestFunction test_func,
|
|
|
|
|
TestContext *perspective,
|
|
|
|
|
TestContext *ctx,
|
|
|
|
|
ExecutionMode exec_mode) :
|
|
|
|
|
AbstractPityUnit(parent, name, exec_mode),
|
|
|
|
|
_perspective{ perspective }, _test_func{ test_func }
|
|
|
|
|
_ctx{ ctx }, _test_func{ test_func }
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -50,15 +50,15 @@ namespace pEp {
|
|
|
|
|
PityUnit<TestContext>::PityUnit(const PityUnit<TestContext> &rhs) :
|
|
|
|
|
AbstractPityUnit(rhs, *this)
|
|
|
|
|
{
|
|
|
|
|
_perspective = rhs._perspective;
|
|
|
|
|
_test_func = rhs._test_func;
|
|
|
|
|
_copyContext(rhs);
|
|
|
|
|
_test_func = TestFunction(rhs._test_func);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<class TestContext>
|
|
|
|
|
PityUnit<TestContext> &PityUnit<TestContext>::operator=(const PityUnit<TestContext> &rhs)
|
|
|
|
|
{
|
|
|
|
|
_perspective = rhs._perspective;
|
|
|
|
|
_test_func = rhs._test_func;
|
|
|
|
|
_copyContext(rhs);
|
|
|
|
|
_test_func = TestFunction(rhs._test_func);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -73,7 +73,7 @@ namespace pEp {
|
|
|
|
|
{
|
|
|
|
|
if (_test_func != nullptr) {
|
|
|
|
|
try {
|
|
|
|
|
_test_func(*this, getPerspective());
|
|
|
|
|
_test_func(*this, getContext());
|
|
|
|
|
logH3(_status_string("\033[1m\033[32mSUCCESS" + Utils::to_termcol(_color())));
|
|
|
|
|
} catch (const std::exception &e) {
|
|
|
|
|
_logRaw("reason: " + std::string(e.what()));
|
|
|
|
@ -86,20 +86,32 @@ namespace pEp {
|
|
|
|
|
|
|
|
|
|
// Inherited (if null see parent recursively)
|
|
|
|
|
template<class TestContext>
|
|
|
|
|
TestContext *PityUnit<TestContext>::getPerspective() const
|
|
|
|
|
TestContext *PityUnit<TestContext>::getContext() const
|
|
|
|
|
{
|
|
|
|
|
pEpLogClass("called");
|
|
|
|
|
TestContext *ret = nullptr;
|
|
|
|
|
|
|
|
|
|
if (_perspective != nullptr) {
|
|
|
|
|
ret = _perspective;
|
|
|
|
|
if (_ctx != nullptr) {
|
|
|
|
|
ret = _ctx;
|
|
|
|
|
} else {
|
|
|
|
|
if (!isRoot()) {
|
|
|
|
|
ret = (dynamic_cast<PityUnit<TestContext> *>(getParent()))->getPerspective();
|
|
|
|
|
ret = (dynamic_cast<PityUnit<TestContext> *>(getParent()))->getContext();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<class TestContext>
|
|
|
|
|
void PityUnit<TestContext>::_copyContext(const PityUnit<TestContext> &rhs)
|
|
|
|
|
{
|
|
|
|
|
auto *tmp = rhs.getContext();
|
|
|
|
|
if (tmp != nullptr) {
|
|
|
|
|
_owned_ctx = std::shared_ptr<TestContext>(new TestContext(*tmp));
|
|
|
|
|
_ctx = tmp;
|
|
|
|
|
} else {
|
|
|
|
|
_ctx = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // namespace PityTest11
|
|
|
|
|
} // namespace pEp
|
|
|
|
|
|
|
|
|
|