aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing
diff options
context:
space:
mode:
authornga <nga@yandex-team.ru>2022-02-10 16:48:09 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:09 +0300
commitc2a1af049e9deca890e9923abe64fe6c59060348 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/testing
parent1f553f46fb4f3c5eec631352cdd900a0709016af (diff)
downloadydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing')
-rw-r--r--library/cpp/testing/unittest/registar.cpp18
-rw-r--r--library/cpp/testing/unittest/registar.h24
-rw-r--r--library/cpp/testing/unittest/utmain.cpp54
3 files changed, 48 insertions, 48 deletions
diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp
index bfb87970d1..3679b768ed 100644
--- a/library/cpp/testing/unittest/registar.cpp
+++ b/library/cpp/testing/unittest/registar.cpp
@@ -5,10 +5,10 @@
#include <util/generic/bt_exception.h>
#include <util/random/fast.h>
-#include <util/string/printf.h>
+#include <util/string/printf.h>
#include <util/system/backtrace.h>
#include <util/system/guard.h>
-#include <util/system/tls.h>
+#include <util/system/tls.h>
#include <util/system/error.h>
#include <util/string/cast.h>
@@ -27,13 +27,13 @@ TString NUnitTest::RandomString(size_t len, ui32 seed) {
return ret;
}
-
+
Y_POD_STATIC_THREAD(bool)
UnittestThread;
Y_POD_STATIC_THREAD(NUnitTest::TTestBase*)
currentTest;
::NUnitTest::TRaiseErrorHandler RaiseErrorHandler;
-
+
void ::NUnitTest::NPrivate::RaiseError(const char* what, const TString& msg, bool fatalFailure) {
Y_VERIFY(UnittestThread, "%s in non-unittest thread with message:\n%s", what, msg.data());
Y_VERIFY(GetCurrentTest());
@@ -51,17 +51,17 @@ void ::NUnitTest::NPrivate::RaiseError(const char* what, const TString& msg, boo
return;
}
throw TAssertException();
-}
-
+}
+
void ::NUnitTest::SetRaiseErrorHandler(::NUnitTest::TRaiseErrorHandler handler) {
Y_VERIFY(UnittestThread);
RaiseErrorHandler = std::move(handler);
}
-void ::NUnitTest::NPrivate::SetUnittestThread(bool unittestThread) {
+void ::NUnitTest::NPrivate::SetUnittestThread(bool unittestThread) {
Y_VERIFY(UnittestThread != unittestThread, "state check");
- UnittestThread = unittestThread;
-}
+ UnittestThread = unittestThread;
+}
void ::NUnitTest::NPrivate::SetCurrentTest(TTestBase* test) {
Y_VERIFY(!test || !currentTest, "state check");
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h
index 594e6681e7..44517a0092 100644
--- a/library/cpp/testing/unittest/registar.h
+++ b/library/cpp/testing/unittest/registar.h
@@ -38,7 +38,7 @@ namespace NUnitTest {
void SetCurrentTest(TTestBase*);
TTestBase* GetCurrentTest();
}
-
+
extern bool ShouldColorizeDiff;
extern bool ContinueOnFail;
TString ColoredDiff(TStringBuf s1, TStringBuf s2, const TString& delims = TString(), bool reverse = false);
@@ -122,19 +122,19 @@ namespace NUnitTest {
void Finish(const TFinish& descr);
unsigned GoodTests() const noexcept;
-
+
unsigned FailTests() const noexcept;
unsigned GoodTestsInCurrentUnit() const noexcept;
unsigned FailTestsInCurrentUnit() const noexcept;
- // Should execute test suite?
+ // Should execute test suite?
virtual bool CheckAccess(TString /*name*/, size_t /*num*/);
- // Should execute a test whitin suite?
+ // Should execute a test whitin suite?
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
@@ -157,7 +157,7 @@ namespace NUnitTest {
virtual void OnFinish(const TFinish* /*finish*/);
virtual void OnBeforeTest(const TTest* /*test*/);
-
+
void AddTestError(const TTest& test);
void AddTestFinish(const TTest& test);
@@ -176,7 +176,7 @@ namespace NUnitTest {
virtual ~ITestBaseFactory();
- // name of test suite
+ // name of test suite
virtual TString Name() const noexcept = 0;
virtual TTestBase* ConstructTest() = 0;
@@ -210,9 +210,9 @@ namespace NUnitTest {
protected:
bool CheckAccessTest(const char* test);
-
+
void BeforeTest(const char* func);
-
+
void Finish(const char* func, TTestContext* context);
void AtStart();
@@ -433,7 +433,7 @@ public: \
auto&& failMsg = Sprintf("%s != %s %s", ToString(_a).data(), ToString(_b).data(), (::TStringBuilder() << C).data()); \
UNIT_FAIL_IMPL("strings equal assertion failed", failMsg); \
} \
- } while (false)
+ } while (false)
#define UNIT_ASSERT_STRINGS_EQUAL(A, B) UNIT_ASSERT_STRINGS_EQUAL_C(A, B, "")
@@ -702,7 +702,7 @@ public: \
return false;
}
}
-
+
//values
#define UNIT_ASSERT_VALUES_EQUAL_IMPL(A, B, C, EQflag, EQstr, NEQstr) \
do { \
@@ -720,7 +720,7 @@ public: \
UNIT_FAIL_IMPL("assertion failed", failMsg); \
} \
} while (false)
-
+
#define UNIT_ASSERT_VALUES_EQUAL_C(A, B, C) \
UNIT_ASSERT_VALUES_EQUAL_IMPL(A, B, C, true, "==", "!=")
diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp
index 6cc2bfbbb1..305bc6b40f 100644
--- a/library/cpp/testing/unittest/utmain.cpp
+++ b/library/cpp/testing/unittest/utmain.cpp
@@ -216,7 +216,7 @@ public:
inline void SetPrintBeforeSuite(bool print) {
PrintBeforeSuite_ = print;
}
-
+
inline void SetPrintAfterSuite(bool print) {
PrintAfterSuite_ = print;
}
@@ -224,7 +224,7 @@ public:
inline void SetPrintBeforeTest(bool print) {
PrintBeforeTest_ = print;
}
-
+
inline void SetPrintAfterTest(bool print) {
PrintAfterTest_ = print;
}
@@ -286,7 +286,7 @@ public:
inline void SetLoop(bool loop) {
Loop = loop;
}
-
+
inline bool IsLoop() const {
return Loop;
}
@@ -300,17 +300,17 @@ private:
TraceProcessor->UnitStart(*unit);
if (IsForked) {
return;
- }
+ }
if (PrintBeforeSuite_ || PrintBeforeTest_) {
fprintf(stderr, "%s<-----%s %s\n", LightBlueColor().data(), OldColor().data(), unit->name.data());
}
}
-
+
void OnUnitStop(const TUnit* unit) override {
TraceProcessor->UnitStop(*unit);
if (IsForked) {
return;
- }
+ }
if (!PrintAfterSuite_) {
return;
}
@@ -329,12 +329,12 @@ private:
TraceProcessor->BeforeTest(*test);
if (IsForked) {
return;
- }
+ }
if (PrintBeforeTest_) {
fprintf(stderr, "[%sexec%s] %s::%s...\n", LightBlueColor().data(), OldColor().data(), test->unit->name.data(), test->name);
}
}
-
+
void OnError(const TError* descr) override {
TraceProcessor->Error(*descr);
if (!IsForked && ForkExitedCorrectly) {
@@ -454,19 +454,19 @@ private:
if (EnabledTests_.empty()) {
return true;
}
-
+
if (EnabledTests_.find(TString() + suite + "::*") != EnabledTests_.end()) {
return true;
}
-
+
return EnabledTests_.find(name) != EnabledTests_.end();
}
-
+
void Run(std::function<void()> f, const TString& suite, const char* name, const bool forceFork) override {
if (!(ForkTests || forceFork) || GetIsForked()) {
return f();
- }
-
+ }
+
TList<TString> args(1, "--is-forked-internal");
args.push_back(Sprintf("+%s::%s", suite.data(), name));
@@ -614,7 +614,7 @@ static int DoUsage(const char* progname) {
<< " -l, --list print a list of available tests\n"
<< " -A --list-verbose print a list of available subtests\n"
<< " --print-before-test print each test name before running it\n"
- << " --print-before-suite print each test suite name before running it\n"
+ << " --print-before-suite print each test suite name before running it\n"
<< " --show-fails print a list of all failed tests at the end\n"
<< " --dont-show-fails do not print a list of all failed tests at the end\n"
<< " --continue-on-fail print a message and continue running test suite instead of break\n"
@@ -686,9 +686,9 @@ int NUnitTest::RunMain(int argc, char** argv) {
} else if (strcmp(name, "--list-verbose") == 0 || strcmp(name, "-A") == 0) {
listTests = LIST_VERBOSE;
} else if (strcmp(name, "--print-before-suite=false") == 0) {
- processor.SetPrintBeforeSuite(false);
- } else if (strcmp(name, "--print-before-test=false") == 0) {
- processor.SetPrintBeforeTest(false);
+ processor.SetPrintBeforeSuite(false);
+ } else if (strcmp(name, "--print-before-test=false") == 0) {
+ processor.SetPrintBeforeTest(false);
} else if (strcmp(name, "--print-before-suite") == 0) {
processor.SetPrintBeforeSuite(true);
} else if (strcmp(name, "--print-before-test") == 0) {
@@ -709,10 +709,10 @@ int NUnitTest::RunMain(int argc, char** argv) {
processor.SetEnd(FromString<size_t>(argv[i]));
} else if (strcmp(name, "--fork-tests") == 0) {
processor.SetForkTests(true);
- } else if (strcmp(name, "--is-forked-internal") == 0) {
+ } else if (strcmp(name, "--is-forked-internal") == 0) {
processor.SetIsForked(true);
- } else if (strcmp(name, "--loop") == 0) {
- processor.SetLoop(true);
+ } else if (strcmp(name, "--loop") == 0) {
+ processor.SetLoop(true);
} else if (strcmp(name, "--trace-path") == 0) {
++i;
processor.BeQuiet();
@@ -733,8 +733,8 @@ int NUnitTest::RunMain(int argc, char** argv) {
size_t assign = param.find('=');
Singleton<::NPrivate::TTestEnv>()->AddTestParam(param.substr(0, assign), param.substr(assign + 1));
} else if (TString(name).StartsWith("--")) {
- return DoUsage(argv[0]), 1;
- } else if (*name == '-') {
+ return DoUsage(argv[0]), 1;
+ } else if (*name == '-') {
processor.Disable(name + 1);
} else if (*name == '+') {
processor.Enable(name + 1);
@@ -750,15 +750,15 @@ int NUnitTest::RunMain(int argc, char** argv) {
TTestFactory::Instance().SetProcessor(&processor);
unsigned ret;
- for (;;) {
+ for (;;) {
ret = TTestFactory::Instance().Execute();
if (!processor.GetIsForked() && ret && processor.GetPrintSummary()) {
- Cerr << "SOME TESTS FAILED!!!!" << Endl;
- }
-
+ Cerr << "SOME TESTS FAILED!!!!" << Endl;
+ }
+
if (0 != ret || !processor.IsLoop()) {
break;
- }
+ }
}
return ret;
#ifndef UT_SKIP_EXCEPTIONS