From 905141dc3b1c19f2c8d79af65257f4ffa1f919c6 Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 8 Jul 2021 02:45:52 +0200 Subject: [PATCH] Test: PityUnit - Copy C'tor, clone() --- src/PityUnit.hh | 7 +++++-- src/PityUnit.hxx | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/PityUnit.hh b/src/PityUnit.hh index b77d07d..0c04e55 100644 --- a/src/PityUnit.hh +++ b/src/PityUnit.hh @@ -23,7 +23,7 @@ namespace pEp { // Test success if TestFunction: // * does not throw // * returns 0 - using TestFunction = const std::function&, TestContext*)>; + using TestFunction = std::function&, TestContext*)>; // Constructors are private PityUnit() = delete; @@ -40,11 +40,14 @@ namespace pEp { TestContext* perspective = nullptr, ExecutionMode exec_mode = ExecutionMode::FUNCTION); + PityUnit(const PityUnit &rhs); + PityUnit *clone() override; + // Read-Only TestContext* getPerspective() const; private: - void _runSelf(); + void _runSelf() override; // Fields TestContext* _perspective; //nullptr if inherited diff --git a/src/PityUnit.hxx b/src/PityUnit.hxx index e9ca1c2..122940d 100644 --- a/src/PityUnit.hxx +++ b/src/PityUnit.hxx @@ -5,6 +5,8 @@ #define PITYTEST_PITYUNIT_HXX #include "../../../src/std_utils.hh" +#include "PityUnit.hh" + #include #include #include @@ -44,6 +46,20 @@ namespace pEp { { } + template + PityUnit::PityUnit(const PityUnit &rhs) : + AbstractPityUnit(rhs, *this) + { + _perspective = rhs._perspective; + _test_func = rhs._test_func; + } + + template + PityUnit *PityUnit::clone() + { + return new PityUnit(*this); + } + template void PityUnit::_runSelf() {