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