diff options
author | aosipenko <aosipenko@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:08 +0300 |
commit | 69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/testing/unittest | |
parent | 948fd24d47d4b3b7815aaef1686aea00ef3f4288 (diff) | |
download | ydb-69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f.tar.gz |
Restoring authorship annotation for <aosipenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing/unittest')
-rw-r--r-- | library/cpp/testing/unittest/checks.cpp | 42 | ||||
-rw-r--r-- | library/cpp/testing/unittest/registar.h | 14 | ||||
-rw-r--r-- | library/cpp/testing/unittest/tests_data.cpp | 6 | ||||
-rw-r--r-- | library/cpp/testing/unittest/tests_data.h | 4 | ||||
-rw-r--r-- | library/cpp/testing/unittest/utmain.cpp | 56 | ||||
-rw-r--r-- | library/cpp/testing/unittest/ya.make | 4 |
6 files changed, 63 insertions, 63 deletions
diff --git a/library/cpp/testing/unittest/checks.cpp b/library/cpp/testing/unittest/checks.cpp index 2fbbde6ceb..c5712ae9d2 100644 --- a/library/cpp/testing/unittest/checks.cpp +++ b/library/cpp/testing/unittest/checks.cpp @@ -1,31 +1,31 @@ #include <util/generic/string.h> #include <util/string/type.h> - + bool CheckExceptionMessage(const char* msg, TString& err) { - static const char* badMsg[] = { + static const char* badMsg[] = { // Операция успешно завершена [cp1251] "\xce\xef\xe5\xf0\xe0\xf6\xe8\xff\x20\xf3\xf1\xef\xe5\xf8\xed\xee\x20\xe7\xe0\xe2\xe5\xf0\xf8\xe5\xed\xe0", - "The operation completed successfully", + "The operation completed successfully", "No error"}; - - err.clear(); - + + err.clear(); + if (msg == nullptr) { - err = "Error message is null"; - return false; - } - - if (IsSpace(msg)) { - err = "Error message is empty"; - return false; - } - + err = "Error message is null"; + return false; + } + + if (IsSpace(msg)) { + err = "Error message is empty"; + return false; + } + for (auto& i : badMsg) { if (strstr(msg, i) != nullptr) { err = "Invalid error message: " + TString(msg); - return false; - } - } - - return true; -} + return false; + } + } + + return true; +} diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h index d8db81d556..44517a0092 100644 --- a/library/cpp/testing/unittest/registar.h +++ b/library/cpp/testing/unittest/registar.h @@ -7,7 +7,7 @@ #include <util/generic/intrlist.h> #include <util/generic/map.h> #include <util/generic/ptr.h> -#include <util/generic/set.h> +#include <util/generic/set.h> #include <util/generic/typetraits.h> #include <util/generic/vector.h> #include <util/generic/yexception.h> @@ -86,19 +86,19 @@ namespace NUnitTest { }; struct TTest { - const TUnit* unit; - const char* name; + const TUnit* unit; + const char* name; }; struct TError { - const TTest* test; - const char* msg; + const TTest* test; + const char* msg; TString BackTrace; TTestContext* Context; }; struct TFinish { - const TTest* test; + const TTest* test; TTestContext* Context; bool Success; }; @@ -790,7 +790,7 @@ public: \ } inline TString Name() const noexcept override { - return T::StaticName(); + return T::StaticName(); } }; diff --git a/library/cpp/testing/unittest/tests_data.cpp b/library/cpp/testing/unittest/tests_data.cpp index 8aa7d6eaa7..b51cbc4b87 100644 --- a/library/cpp/testing/unittest/tests_data.cpp +++ b/library/cpp/testing/unittest/tests_data.cpp @@ -1,8 +1,8 @@ -#include "tests_data.h" +#include "tests_data.h" #include "registar.h" - + #include <library/cpp/testing/common/network.h> - + #include <util/system/env.h> #include <util/system/mutex.h> diff --git a/library/cpp/testing/unittest/tests_data.h b/library/cpp/testing/unittest/tests_data.h index 4643a77e38..6536bc1ae6 100644 --- a/library/cpp/testing/unittest/tests_data.h +++ b/library/cpp/testing/unittest/tests_data.h @@ -1,12 +1,12 @@ #pragma once - + #include <library/cpp/testing/common/env.h> #include <util/generic/noncopyable.h> #include <util/generic/ptr.h> #include <util/generic/string.h> #include <util/network/sock.h> - + class TInet6StreamSocket; // set two options: SO_REUSEADDR and SO_REUSEPORT, both are required for diff --git a/library/cpp/testing/unittest/utmain.cpp b/library/cpp/testing/unittest/utmain.cpp index d9fc967886..305bc6b40f 100644 --- a/library/cpp/testing/unittest/utmain.cpp +++ b/library/cpp/testing/unittest/utmain.cpp @@ -83,7 +83,7 @@ private: inline void TraceSubtestFinished(const char* className, const char* subtestName, const char* status, const TString comment, const TTestContext* context) { const TInstant now = TInstant::Now(); - NJson::TJsonValue event; + NJson::TJsonValue event; event.InsertValue("class", className); event.InsertValue("subtest", subtestName); event.InsertValue("status", status); @@ -116,7 +116,7 @@ private: } void OnBeforeTest(const TTest* test) override { - NJson::TJsonValue event; + NJson::TJsonValue event; event.InsertValue("class", test->unit->name); event.InsertValue("subtest", test->name); Trace("subtest-started", event); @@ -128,13 +128,13 @@ private: } void OnUnitStart(const TUnit* unit) override { - NJson::TJsonValue event; + NJson::TJsonValue event; event.InsertValue("class", unit->name); Trace("test-started", event); } void OnUnitStop(const TUnit* unit) override { - NJson::TJsonValue event; + NJson::TJsonValue event; event.InsertValue("class", unit->name); Trace("test-finished", event); } @@ -417,7 +417,7 @@ private: fprintf(stderr, ", err: %s%u%s", LightRedColor().data(), FailTests(), OldColor().data()); fprintf(stderr, "\n"); - + if (ShowFails) { for (size_t i = 0; i < Fails.size(); ++i) { printf("%s", Fails[i].data()); @@ -567,16 +567,16 @@ private: IOutputStream& Stream_; }; -#ifdef _win_ -class TWinEnvironment { -public: - TWinEnvironment() +#ifdef _win_ +class TWinEnvironment { +public: + TWinEnvironment() : OutputCP(GetConsoleOutputCP()) - { - setmode(fileno(stdout), _O_BINARY); - SetConsoleOutputCP(CP_UTF8); - - _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); + { + setmode(fileno(stdout), _O_BINARY); + SetConsoleOutputCP(CP_UTF8); + + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); if (!IsDebuggerPresent()) { _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); @@ -586,20 +586,20 @@ public: } } ~TWinEnvironment() { - if (!IsDebuggerPresent()) { - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - } - - SetConsoleOutputCP(OutputCP); // restore original output CP at program exit - } - -private: - UINT OutputCP; // original codepage -}; -static const TWinEnvironment Instance; -#endif // _win_ - + if (!IsDebuggerPresent()) { + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + } + + SetConsoleOutputCP(OutputCP); // restore original output CP at program exit + } + +private: + UINT OutputCP; // original codepage +}; +static const TWinEnvironment Instance; +#endif // _win_ + static int DoList(bool verbose, IOutputStream& stream) { TEnumeratingProcessor eproc(verbose, stream); TTestFactory::Instance().SetProcessor(&eproc); diff --git a/library/cpp/testing/unittest/ya.make b/library/cpp/testing/unittest/ya.make index bdc71c13cc..aaa4f2ba85 100644 --- a/library/cpp/testing/unittest/ya.make +++ b/library/cpp/testing/unittest/ya.make @@ -18,10 +18,10 @@ PEERDIR( SRCS( gtest.cpp - checks.cpp + checks.cpp plugin.cpp registar.cpp - tests_data.cpp + tests_data.cpp utmain.cpp ) |