aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing
diff options
context:
space:
mode:
authorstanly <stanly@yandex-team.ru>2022-02-10 16:46:49 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:49 +0300
commitcde218e65dfef5ce03a48d641fd8f7913cf17b2d (patch)
treed3349caea4095825a55b5ba24fe758067b29ce6f /library/cpp/testing
parent9f813499b4ef585cb3c2bb93de93ef003daf4fc4 (diff)
downloadydb-cde218e65dfef5ce03a48d641fd8f7913cf17b2d.tar.gz
Restoring authorship annotation for <stanly@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/testing')
-rw-r--r--library/cpp/testing/unittest/registar.cpp626
-rw-r--r--library/cpp/testing/unittest/registar.h118
2 files changed, 372 insertions, 372 deletions
diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp
index 3679b768ed..b43f9c6a4f 100644
--- a/library/cpp/testing/unittest/registar.cpp
+++ b/library/cpp/testing/unittest/registar.cpp
@@ -155,189 +155,189 @@ TString NUnitTest::ColoredDiff(TStringBuf s1, TStringBuf s2, const TString& deli
}
return res.Str();
}
-
-static TString MakeTestName(const NUnitTest::ITestSuiteProcessor::TTest& test) {
- return TStringBuilder() << test.unit->name << "::" << test.name;
-}
-
+
+static TString MakeTestName(const NUnitTest::ITestSuiteProcessor::TTest& test) {
+ return TStringBuilder() << test.unit->name << "::" << test.name;
+}
+
static size_t CountTests(const TMap<TString, size_t>& testErrors, bool succeeded) {
- size_t cnt = 0;
- for (const auto& t : testErrors) {
- if (succeeded && t.second == 0) {
- ++cnt;
- } else if (!succeeded && t.second > 0) {
- ++cnt;
- }
- }
- return cnt;
-}
-
-NUnitTest::ITestSuiteProcessor::ITestSuiteProcessor() = default;
-
-NUnitTest::ITestSuiteProcessor::~ITestSuiteProcessor() = default;
-
-void NUnitTest::ITestSuiteProcessor::Start() {
- OnStart();
-}
-
-void NUnitTest::ITestSuiteProcessor::End() {
- OnEnd();
-}
-
-void NUnitTest::ITestSuiteProcessor::UnitStart(const TUnit& unit) {
- CurTestErrors_.clear();
-
- OnUnitStart(&unit);
-}
-
-void NUnitTest::ITestSuiteProcessor::UnitStop(const TUnit& unit) {
- OnUnitStop(&unit);
-}
-
-void NUnitTest::ITestSuiteProcessor::Error(const TError& descr) {
- AddTestError(*descr.test);
-
- OnError(&descr);
-}
-
-void NUnitTest::ITestSuiteProcessor::BeforeTest(const TTest& test) {
- OnBeforeTest(&test);
-}
-
-void NUnitTest::ITestSuiteProcessor::Finish(const TFinish& descr) {
- AddTestFinish(*descr.test);
-
- OnFinish(&descr);
-}
-
-unsigned NUnitTest::ITestSuiteProcessor::GoodTests() const noexcept {
- return CountTests(TestErrors_, true);
-}
-
-unsigned NUnitTest::ITestSuiteProcessor::FailTests() const noexcept {
- return CountTests(TestErrors_, false);
-}
-
-unsigned NUnitTest::ITestSuiteProcessor::GoodTestsInCurrentUnit() const noexcept {
- return CountTests(CurTestErrors_, true);
-}
-
-unsigned NUnitTest::ITestSuiteProcessor::FailTestsInCurrentUnit() const noexcept {
- return CountTests(CurTestErrors_, false);
-}
-
-bool NUnitTest::ITestSuiteProcessor::CheckAccess(TString /*name*/, size_t /*num*/) {
- return true;
-}
-
-bool NUnitTest::ITestSuiteProcessor::CheckAccessTest(TString /*suite*/, const char* /*name*/) {
- return true;
-}
-
+ size_t cnt = 0;
+ for (const auto& t : testErrors) {
+ if (succeeded && t.second == 0) {
+ ++cnt;
+ } else if (!succeeded && t.second > 0) {
+ ++cnt;
+ }
+ }
+ return cnt;
+}
+
+NUnitTest::ITestSuiteProcessor::ITestSuiteProcessor() = default;
+
+NUnitTest::ITestSuiteProcessor::~ITestSuiteProcessor() = default;
+
+void NUnitTest::ITestSuiteProcessor::Start() {
+ OnStart();
+}
+
+void NUnitTest::ITestSuiteProcessor::End() {
+ OnEnd();
+}
+
+void NUnitTest::ITestSuiteProcessor::UnitStart(const TUnit& unit) {
+ CurTestErrors_.clear();
+
+ OnUnitStart(&unit);
+}
+
+void NUnitTest::ITestSuiteProcessor::UnitStop(const TUnit& unit) {
+ OnUnitStop(&unit);
+}
+
+void NUnitTest::ITestSuiteProcessor::Error(const TError& descr) {
+ AddTestError(*descr.test);
+
+ OnError(&descr);
+}
+
+void NUnitTest::ITestSuiteProcessor::BeforeTest(const TTest& test) {
+ OnBeforeTest(&test);
+}
+
+void NUnitTest::ITestSuiteProcessor::Finish(const TFinish& descr) {
+ AddTestFinish(*descr.test);
+
+ OnFinish(&descr);
+}
+
+unsigned NUnitTest::ITestSuiteProcessor::GoodTests() const noexcept {
+ return CountTests(TestErrors_, true);
+}
+
+unsigned NUnitTest::ITestSuiteProcessor::FailTests() const noexcept {
+ return CountTests(TestErrors_, false);
+}
+
+unsigned NUnitTest::ITestSuiteProcessor::GoodTestsInCurrentUnit() const noexcept {
+ return CountTests(CurTestErrors_, true);
+}
+
+unsigned NUnitTest::ITestSuiteProcessor::FailTestsInCurrentUnit() const noexcept {
+ return CountTests(CurTestErrors_, false);
+}
+
+bool NUnitTest::ITestSuiteProcessor::CheckAccess(TString /*name*/, size_t /*num*/) {
+ return true;
+}
+
+bool NUnitTest::ITestSuiteProcessor::CheckAccessTest(TString /*suite*/, const char* /*name*/) {
+ return true;
+}
+
void NUnitTest::ITestSuiteProcessor::Run(std::function<void()> f, const TString& /*suite*/, const char* /*name*/, const bool /*forceFork*/) {
- f();
-}
-
-bool NUnitTest::ITestSuiteProcessor::GetIsForked() const {
- return false;
-}
-
-bool NUnitTest::ITestSuiteProcessor::GetForkTests() const {
- return false;
-}
-
-void NUnitTest::ITestSuiteProcessor::OnStart() {
-}
-
-void NUnitTest::ITestSuiteProcessor::OnEnd() {
-}
-
-void NUnitTest::ITestSuiteProcessor::OnUnitStart(const TUnit* /*unit*/) {
-}
-
-void NUnitTest::ITestSuiteProcessor::OnUnitStop(const TUnit* /*unit*/) {
-}
-
-void NUnitTest::ITestSuiteProcessor::OnError(const TError* /*error*/) {
-}
-
-void NUnitTest::ITestSuiteProcessor::OnFinish(const TFinish* /*finish*/) {
-}
-
-void NUnitTest::ITestSuiteProcessor::OnBeforeTest(const TTest* /*test*/) {
-}
-
-void NUnitTest::ITestSuiteProcessor::AddTestError(const TTest& test) {
- const TString name = MakeTestName(test);
- ++TestErrors_[name];
- ++CurTestErrors_[name];
-}
-
-void NUnitTest::ITestSuiteProcessor::AddTestFinish(const TTest& test) {
- const TString name = MakeTestName(test);
- TestErrors_[name]; // zero errors if not touched
- CurTestErrors_[name]; // zero errors if not touched
-}
-
-NUnitTest::ITestBaseFactory::ITestBaseFactory() {
- Register();
-}
-
-NUnitTest::ITestBaseFactory::~ITestBaseFactory() = default;
-
-void NUnitTest::ITestBaseFactory::Register() noexcept {
- TTestFactory::Instance().Register(this);
-}
-
-NUnitTest::TTestBase::TTestBase() noexcept
+ f();
+}
+
+bool NUnitTest::ITestSuiteProcessor::GetIsForked() const {
+ return false;
+}
+
+bool NUnitTest::ITestSuiteProcessor::GetForkTests() const {
+ return false;
+}
+
+void NUnitTest::ITestSuiteProcessor::OnStart() {
+}
+
+void NUnitTest::ITestSuiteProcessor::OnEnd() {
+}
+
+void NUnitTest::ITestSuiteProcessor::OnUnitStart(const TUnit* /*unit*/) {
+}
+
+void NUnitTest::ITestSuiteProcessor::OnUnitStop(const TUnit* /*unit*/) {
+}
+
+void NUnitTest::ITestSuiteProcessor::OnError(const TError* /*error*/) {
+}
+
+void NUnitTest::ITestSuiteProcessor::OnFinish(const TFinish* /*finish*/) {
+}
+
+void NUnitTest::ITestSuiteProcessor::OnBeforeTest(const TTest* /*test*/) {
+}
+
+void NUnitTest::ITestSuiteProcessor::AddTestError(const TTest& test) {
+ const TString name = MakeTestName(test);
+ ++TestErrors_[name];
+ ++CurTestErrors_[name];
+}
+
+void NUnitTest::ITestSuiteProcessor::AddTestFinish(const TTest& test) {
+ const TString name = MakeTestName(test);
+ TestErrors_[name]; // zero errors if not touched
+ CurTestErrors_[name]; // zero errors if not touched
+}
+
+NUnitTest::ITestBaseFactory::ITestBaseFactory() {
+ Register();
+}
+
+NUnitTest::ITestBaseFactory::~ITestBaseFactory() = default;
+
+void NUnitTest::ITestBaseFactory::Register() noexcept {
+ TTestFactory::Instance().Register(this);
+}
+
+NUnitTest::TTestBase::TTestBase() noexcept
: Parent_(nullptr)
, TestErrors_()
, CurrentSubtest_()
{
-}
-
-NUnitTest::TTestBase::~TTestBase() = default;
-
-TString NUnitTest::TTestBase::TypeId() const {
+}
+
+NUnitTest::TTestBase::~TTestBase() = default;
+
+TString NUnitTest::TTestBase::TypeId() const {
return TypeName(*this);
-}
-
-void NUnitTest::TTestBase::SetUp() {
-}
-
-void NUnitTest::TTestBase::TearDown() {
-}
-
+}
+
+void NUnitTest::TTestBase::SetUp() {
+}
+
+void NUnitTest::TTestBase::TearDown() {
+}
+
void NUnitTest::TTestBase::AddError(const char* msg, const TString& backtrace, TTestContext* context) {
- ++TestErrors_;
- const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
- const NUnitTest::ITestSuiteProcessor::TTest test = {&unit, CurrentSubtest_};
- const NUnitTest::ITestSuiteProcessor::TError err = {&test, msg, backtrace, context};
-
- Processor()->Error(err);
-}
-
+ ++TestErrors_;
+ const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
+ const NUnitTest::ITestSuiteProcessor::TTest test = {&unit, CurrentSubtest_};
+ const NUnitTest::ITestSuiteProcessor::TError err = {&test, msg, backtrace, context};
+
+ Processor()->Error(err);
+}
+
void NUnitTest::TTestBase::AddError(const char* msg, TTestContext* context) {
- AddError(msg, TString(), context);
-}
-
+ AddError(msg, TString(), context);
+}
+
void NUnitTest::TTestBase::RunAfterTest(std::function<void()> f) {
with_lock (AfterTestFunctionsLock_) {
AfterTestFunctions_.emplace_back(std::move(f));
}
}
-bool NUnitTest::TTestBase::CheckAccessTest(const char* test) {
- return Processor()->CheckAccessTest(Name(), test);
-}
-
-void NUnitTest::TTestBase::BeforeTest(const char* func) {
- const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
- const NUnitTest::ITestSuiteProcessor::TTest test = {&unit, func};
+bool NUnitTest::TTestBase::CheckAccessTest(const char* test) {
+ return Processor()->CheckAccessTest(Name(), test);
+}
+
+void NUnitTest::TTestBase::BeforeTest(const char* func) {
+ const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
+ const NUnitTest::ITestSuiteProcessor::TTest test = {&unit, func};
rusage.Fill();
- Processor()->BeforeTest(test);
-}
-
+ Processor()->BeforeTest(test);
+}
+
void NUnitTest::TTestBase::Finish(const char* func, TTestContext* context) {
TRusage finishRusage = TRusage::Get();
context->Metrics["ru_rss"] = finishRusage.MaxRss - rusage.MaxRss;
@@ -345,37 +345,37 @@ void NUnitTest::TTestBase::Finish(const char* func, TTestContext* context) {
context->Metrics["ru_utime"] = (finishRusage.Utime - rusage.Utime).MicroSeconds();
context->Metrics["ru_stime"] = (finishRusage.Stime - rusage.Stime).MicroSeconds();
- const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
- const NUnitTest::ITestSuiteProcessor::TTest test = {&unit, func};
- const NUnitTest::ITestSuiteProcessor::TFinish finish = {&test, context, TestErrors_ == 0};
-
- Processor()->Finish(finish);
-}
-
-void NUnitTest::TTestBase::AtStart() {
- const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
-
- Processor()->UnitStart(unit);
-}
-
-void NUnitTest::TTestBase::AtEnd() {
- const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
-
- Processor()->UnitStop(unit);
-}
-
+ const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
+ const NUnitTest::ITestSuiteProcessor::TTest test = {&unit, func};
+ const NUnitTest::ITestSuiteProcessor::TFinish finish = {&test, context, TestErrors_ == 0};
+
+ Processor()->Finish(finish);
+}
+
+void NUnitTest::TTestBase::AtStart() {
+ const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
+
+ Processor()->UnitStart(unit);
+}
+
+void NUnitTest::TTestBase::AtEnd() {
+ const NUnitTest::ITestSuiteProcessor::TUnit unit = {Name()};
+
+ Processor()->UnitStop(unit);
+}
+
void NUnitTest::TTestBase::Run(std::function<void()> f, const TString& suite, const char* name, const bool forceFork) {
- TestErrors_ = 0;
- CurrentSubtest_ = name;
- Processor()->Run(f, suite, name, forceFork);
-}
-
-void NUnitTest::TTestBase::BeforeTest() {
- SetUp();
-}
-
-void NUnitTest::TTestBase::AfterTest() {
- TearDown();
+ TestErrors_ = 0;
+ CurrentSubtest_ = name;
+ Processor()->Run(f, suite, name, forceFork);
+}
+
+void NUnitTest::TTestBase::BeforeTest() {
+ SetUp();
+}
+
+void NUnitTest::TTestBase::AfterTest() {
+ TearDown();
TVector<std::function<void()>> afterTestFunctions;
with_lock (AfterTestFunctionsLock_) {
@@ -388,126 +388,126 @@ void NUnitTest::TTestBase::AfterTest() {
f();
}
}
-}
-
-bool NUnitTest::TTestBase::GetIsForked() const {
- return Processor()->GetIsForked();
-}
-
-bool NUnitTest::TTestBase::GetForkTests() const {
- return Processor()->GetForkTests();
-}
-
-NUnitTest::ITestSuiteProcessor* NUnitTest::TTestBase::Processor() const noexcept {
- return Parent_->Processor();
-}
-
-NUnitTest::TTestBase::TCleanUp::TCleanUp(TTestBase* base)
- : Base_(base)
-{
- ::NUnitTest::NPrivate::SetCurrentTest(base);
- ::NUnitTest::NPrivate::SetUnittestThread(true);
- Base_->BeforeTest();
-}
-
-NUnitTest::TTestBase::TCleanUp::~TCleanUp() {
- try {
- Base_->AfterTest();
- } catch (...) {
+}
+
+bool NUnitTest::TTestBase::GetIsForked() const {
+ return Processor()->GetIsForked();
+}
+
+bool NUnitTest::TTestBase::GetForkTests() const {
+ return Processor()->GetForkTests();
+}
+
+NUnitTest::ITestSuiteProcessor* NUnitTest::TTestBase::Processor() const noexcept {
+ return Parent_->Processor();
+}
+
+NUnitTest::TTestBase::TCleanUp::TCleanUp(TTestBase* base)
+ : Base_(base)
+{
+ ::NUnitTest::NPrivate::SetCurrentTest(base);
+ ::NUnitTest::NPrivate::SetUnittestThread(true);
+ Base_->BeforeTest();
+}
+
+NUnitTest::TTestBase::TCleanUp::~TCleanUp() {
+ try {
+ Base_->AfterTest();
+ } catch (...) {
Base_->AddError(CurrentExceptionMessage().data());
- }
- ::NUnitTest::NPrivate::SetUnittestThread(false);
- ::NUnitTest::NPrivate::SetCurrentTest(nullptr);
-}
-
-namespace {
- /*
- * by default do nothing
- */
- class TCommonProcessor: public NUnitTest::ITestSuiteProcessor {
- public:
- TCommonProcessor() = default;
-
- ~TCommonProcessor() override = default;
- };
-
- struct TCmp {
- template <class T>
- inline bool operator()(const T& l, const T& r) const noexcept {
+ }
+ ::NUnitTest::NPrivate::SetUnittestThread(false);
+ ::NUnitTest::NPrivate::SetCurrentTest(nullptr);
+}
+
+namespace {
+ /*
+ * by default do nothing
+ */
+ class TCommonProcessor: public NUnitTest::ITestSuiteProcessor {
+ public:
+ TCommonProcessor() = default;
+
+ ~TCommonProcessor() override = default;
+ };
+
+ struct TCmp {
+ template <class T>
+ inline bool operator()(const T& l, const T& r) const noexcept {
return stricmp(Fix(l.Name().data()), Fix(r.Name().data())) < 0;
- }
-
- static inline const char* Fix(const char* n) noexcept {
- if (*n == 'T') {
- return n + 1;
- }
-
- return n;
- }
- };
-}
-
-NUnitTest::TTestFactory::TTestFactory(ITestSuiteProcessor* processor)
- : Processor_(processor)
-{
-}
-
-NUnitTest::TTestFactory::~TTestFactory() = default;
-
-NUnitTest::TTestFactory& NUnitTest::TTestFactory::Instance() {
- static TCommonProcessor p;
- static TTestFactory f(&p);
-
- return f;
-}
-
-unsigned NUnitTest::TTestFactory::Execute() {
- Items_.QuickSort(TCmp());
- Processor_->Start();
-
+ }
+
+ static inline const char* Fix(const char* n) noexcept {
+ if (*n == 'T') {
+ return n + 1;
+ }
+
+ return n;
+ }
+ };
+}
+
+NUnitTest::TTestFactory::TTestFactory(ITestSuiteProcessor* processor)
+ : Processor_(processor)
+{
+}
+
+NUnitTest::TTestFactory::~TTestFactory() = default;
+
+NUnitTest::TTestFactory& NUnitTest::TTestFactory::Instance() {
+ static TCommonProcessor p;
+ static TTestFactory f(&p);
+
+ return f;
+}
+
+unsigned NUnitTest::TTestFactory::Execute() {
+ Items_.QuickSort(TCmp());
+ Processor_->Start();
+
TSet<TString> types;
- size_t cnt = 0;
-
- for (TIntrusiveList<ITestBaseFactory>::TIterator factory = Items_.Begin(); factory != Items_.End(); ++factory) {
- if (!Processor_->CheckAccess(factory->Name(), cnt++)) {
- continue;
- }
-
- THolder<TTestBase> test(factory->ConstructTest());
-
-#ifdef _unix_ // on Windows RTTI causes memory leaks
- TString type = test->TypeId();
- if (types.insert(type).second == false) {
+ size_t cnt = 0;
+
+ for (TIntrusiveList<ITestBaseFactory>::TIterator factory = Items_.Begin(); factory != Items_.End(); ++factory) {
+ if (!Processor_->CheckAccess(factory->Name(), cnt++)) {
+ continue;
+ }
+
+ THolder<TTestBase> test(factory->ConstructTest());
+
+#ifdef _unix_ // on Windows RTTI causes memory leaks
+ TString type = test->TypeId();
+ if (types.insert(type).second == false) {
warnx("Duplicate suite found: %s (%s). Probably you have copy-pasted suite without changing it name", factory->Name().c_str(), type.c_str());
- return 1;
- }
-#endif // _unix_
-
- test->Parent_ = this;
-
+ return 1;
+ }
+#endif // _unix_
+
+ test->Parent_ = this;
+
#ifdef UT_SKIP_EXCEPTIONS
- try {
-#endif
- test->Execute();
+ try {
+#endif
+ test->Execute();
#ifdef UT_SKIP_EXCEPTIONS
- } catch (...) {
- }
-#endif
- }
-
- Processor_->End();
-
+ } catch (...) {
+ }
+#endif
+ }
+
+ Processor_->End();
+
return bool(Processor_->FailTests());
-}
-
-void NUnitTest::TTestFactory::SetProcessor(ITestSuiteProcessor* processor) {
- Processor_ = processor;
-}
-
-void NUnitTest::TTestFactory::Register(ITestBaseFactory* b) noexcept {
- Items_.PushBack(b);
-}
-
-NUnitTest::ITestSuiteProcessor* NUnitTest::TTestFactory::Processor() const noexcept {
- return Processor_;
-}
+}
+
+void NUnitTest::TTestFactory::SetProcessor(ITestSuiteProcessor* processor) {
+ Processor_ = processor;
+}
+
+void NUnitTest::TTestFactory::Register(ITestBaseFactory* b) noexcept {
+ Items_.PushBack(b);
+}
+
+NUnitTest::ITestSuiteProcessor* NUnitTest::TTestFactory::Processor() const noexcept {
+ return Processor_;
+}
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h
index 44517a0092..3aaf80ebe9 100644
--- a/library/cpp/testing/unittest/registar.h
+++ b/library/cpp/testing/unittest/registar.h
@@ -3,13 +3,13 @@
#include <library/cpp/dbg_output/dump.h>
#include <util/generic/bt_exception.h>
-#include <util/generic/hash.h>
+#include <util/generic/hash.h>
#include <util/generic/intrlist.h>
-#include <util/generic/map.h>
+#include <util/generic/map.h>
#include <util/generic/ptr.h>
#include <util/generic/set.h>
#include <util/generic/typetraits.h>
-#include <util/generic/vector.h>
+#include <util/generic/vector.h>
#include <util/generic/yexception.h>
#include <util/string/builder.h>
@@ -103,64 +103,64 @@ namespace NUnitTest {
bool Success;
};
- ITestSuiteProcessor();
+ ITestSuiteProcessor();
- virtual ~ITestSuiteProcessor();
+ virtual ~ITestSuiteProcessor();
- void Start();
+ void Start();
- void End();
+ void End();
- void UnitStart(const TUnit& unit);
+ void UnitStart(const TUnit& unit);
- void UnitStop(const TUnit& unit);
+ void UnitStop(const TUnit& unit);
- void Error(const TError& descr);
+ void Error(const TError& descr);
- void BeforeTest(const TTest& test);
+ void BeforeTest(const TTest& test);
- void Finish(const TFinish& descr);
+ void Finish(const TFinish& descr);
- unsigned GoodTests() const noexcept;
+ unsigned GoodTests() const noexcept;
- unsigned FailTests() const noexcept;
+ unsigned FailTests() const noexcept;
- unsigned GoodTestsInCurrentUnit() const noexcept;
+ unsigned GoodTestsInCurrentUnit() const noexcept;
- unsigned FailTestsInCurrentUnit() const noexcept;
+ unsigned FailTestsInCurrentUnit() const noexcept;
// Should execute test suite?
- virtual bool CheckAccess(TString /*name*/, size_t /*num*/);
+ virtual bool CheckAccess(TString /*name*/, size_t /*num*/);
// Should execute a test whitin suite?
- virtual bool CheckAccessTest(TString /*suite*/, const char* /*name*/);
+ virtual bool CheckAccessTest(TString /*suite*/, const char* /*name*/);
virtual void Run(std::function<void()> f, const TString& /*suite*/, const char* /*name*/, bool /*forceFork*/);
// This process is forked for current test
- virtual bool GetIsForked() const;
-
+ virtual bool GetIsForked() const;
+
// --fork-tests is set (warning: this may be false, but never the less test will be forked if called inside UNIT_FORKED_TEST)
- virtual bool GetForkTests() const;
+ virtual bool GetForkTests() const;
private:
- virtual void OnStart();
+ virtual void OnStart();
- virtual void OnEnd();
+ virtual void OnEnd();
- virtual void OnUnitStart(const TUnit* /*unit*/);
+ virtual void OnUnitStart(const TUnit* /*unit*/);
- virtual void OnUnitStop(const TUnit* /*unit*/);
+ virtual void OnUnitStop(const TUnit* /*unit*/);
- virtual void OnError(const TError* /*error*/);
+ virtual void OnError(const TError* /*error*/);
- virtual void OnFinish(const TFinish* /*finish*/);
+ virtual void OnFinish(const TFinish* /*finish*/);
- virtual void OnBeforeTest(const TTest* /*test*/);
+ virtual void OnBeforeTest(const TTest* /*test*/);
- void AddTestError(const TTest& test);
+ void AddTestError(const TTest& test);
- void AddTestFinish(const TTest& test);
+ void AddTestFinish(const TTest& test);
private:
TMap<TString, size_t> TestErrors_;
@@ -172,16 +172,16 @@ namespace NUnitTest {
class ITestBaseFactory: public TIntrusiveListItem<ITestBaseFactory> {
public:
- ITestBaseFactory();
+ ITestBaseFactory();
- virtual ~ITestBaseFactory();
+ virtual ~ITestBaseFactory();
// name of test suite
virtual TString Name() const noexcept = 0;
virtual TTestBase* ConstructTest() = 0;
private:
- void Register() noexcept;
+ void Register() noexcept;
};
class TTestBase {
@@ -189,18 +189,18 @@ namespace NUnitTest {
TRusage rusage;
public:
- TTestBase() noexcept;
+ TTestBase() noexcept;
- virtual ~TTestBase();
+ virtual ~TTestBase();
- virtual TString TypeId() const;
+ virtual TString TypeId() const;
virtual TString Name() const noexcept = 0;
virtual void Execute() = 0;
- virtual void SetUp();
+ virtual void SetUp();
- virtual void TearDown();
+ virtual void TearDown();
void AddError(const char* msg, const TString& backtrace = TString(), TTestContext* context = nullptr);
@@ -209,15 +209,15 @@ namespace NUnitTest {
void RunAfterTest(std::function<void()> f); // function like atexit to run after current unit test
protected:
- bool CheckAccessTest(const char* test);
+ bool CheckAccessTest(const char* test);
- void BeforeTest(const char* func);
+ void BeforeTest(const char* func);
void Finish(const char* func, TTestContext* context);
- void AtStart();
+ void AtStart();
- void AtEnd();
+ void AtEnd();
void Run(std::function<void()> f, const TString& suite, const char* name, bool forceFork);
@@ -225,21 +225,21 @@ namespace NUnitTest {
public:
explicit TCleanUp(TTestBase* base);
- ~TCleanUp();
+ ~TCleanUp();
private:
TTestBase* Base_;
};
- void BeforeTest();
-
- void AfterTest();
+ void BeforeTest();
- bool GetIsForked() const;
+ void AfterTest();
- bool GetForkTests() const;
+ bool GetIsForked() const;
- ITestSuiteProcessor* Processor() const noexcept;
+ bool GetForkTests() const;
+
+ ITestSuiteProcessor* Processor() const noexcept;
private:
TTestFactory* Parent_;
@@ -759,21 +759,21 @@ public: \
friend class ITestBaseFactory;
public:
- static TTestFactory& Instance();
+ static TTestFactory& Instance();
- unsigned Execute();
+ unsigned Execute();
- void SetProcessor(ITestSuiteProcessor* processor);
+ void SetProcessor(ITestSuiteProcessor* processor);
private:
- void Register(ITestBaseFactory* b) noexcept;
+ void Register(ITestBaseFactory* b) noexcept;
- ITestSuiteProcessor* Processor() const noexcept;
+ ITestSuiteProcessor* Processor() const noexcept;
private:
explicit TTestFactory(ITestSuiteProcessor* processor);
- ~TTestFactory();
+ ~TTestFactory();
private:
TIntrusiveList<ITestBaseFactory> Items_;
@@ -783,13 +783,13 @@ public: \
template <class T>
class TTestBaseFactory: public ITestBaseFactory {
public:
- ~TTestBaseFactory() override = default;
+ ~TTestBaseFactory() override = default;
- inline TTestBase* ConstructTest() override {
+ inline TTestBase* ConstructTest() override {
return new T;
}
- inline TString Name() const noexcept override {
+ inline TString Name() const noexcept override {
return T::StaticName();
}
};
@@ -804,7 +804,7 @@ public: \
: TBaseTestCase(nullptr, nullptr, false)
{
}
-
+
inline TBaseTestCase(const char* name, std::function<void(TTestContext&)> body, bool forceFork)
: Name_(name)
, Body_(std::move(body))