aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorbkuchin <bkuchin@yandex-team.ru>2022-02-10 16:46:29 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:29 +0300
commitf43ab775d197d300eb67bd4497632b909cd7c2a5 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp
parent2c6ec4e7012419466156d8eb2394a888cccaa800 (diff)
downloadydb-f43ab775d197d300eb67bd4497632b909cd7c2a5.tar.gz
Restoring authorship annotation for <bkuchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/testing/unittest/gtest.cpp2
-rw-r--r--library/cpp/testing/unittest/registar.h100
-rw-r--r--library/cpp/testing/unittest/simple.h14
-rw-r--r--library/cpp/testing/unittest/ut/main.cpp48
4 files changed, 82 insertions, 82 deletions
diff --git a/library/cpp/testing/unittest/gtest.cpp b/library/cpp/testing/unittest/gtest.cpp
index f414ffd0f1..ebad1ea4d6 100644
--- a/library/cpp/testing/unittest/gtest.cpp
+++ b/library/cpp/testing/unittest/gtest.cpp
@@ -47,7 +47,7 @@ namespace {
}
void AddTest(const char* name, void (*body)(TTestContext&), bool forceFork) override {
- Test.Tests.push_back(TBaseTestCase(name, body, forceFork));
+ Test.Tests.push_back(TBaseTestCase(name, body, forceFork));
}
TCurrentTest Test;
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h
index 9994ec027d..44517a0092 100644
--- a/library/cpp/testing/unittest/registar.h
+++ b/library/cpp/testing/unittest/registar.h
@@ -794,25 +794,25 @@ public: \
}
};
- struct TBaseTestCase {
+ struct TBaseTestCase {
// NOTE: since EACH test case is instantiated for listing tests, its
// ctor/dtor are not the best place to do heavy preparations in test fixtures.
//
// Consider using SetUp()/TearDown() methods instead
- inline TBaseTestCase()
- : TBaseTestCase(nullptr, nullptr, false)
+ inline TBaseTestCase()
+ : TBaseTestCase(nullptr, nullptr, false)
{
}
inline TBaseTestCase(const char* name, std::function<void(TTestContext&)> body, bool forceFork)
- : Name_(name)
+ : Name_(name)
, Body_(std::move(body))
- , ForceFork_(forceFork)
+ , ForceFork_(forceFork)
{
}
- virtual ~TBaseTestCase() = default;
+ virtual ~TBaseTestCase() = default;
// Each test case is executed in 3 steps:
//
@@ -822,24 +822,24 @@ public: \
//
// Both SetUp() and TearDown() may use UNIT_* check macros and are only
// called when the test is executed.
-
+
virtual void SetUp(TTestContext& /* context */) {
}
virtual void TearDown(TTestContext& /* context */) {
}
- virtual void Execute_(TTestContext& context) {
- Body_(context);
- }
-
- const char* Name_;
- std::function<void(TTestContext&)> Body_;
- bool ForceFork_;
+ virtual void Execute_(TTestContext& context) {
+ Body_(context);
+ }
+
+ const char* Name_;
+ std::function<void(TTestContext&)> Body_;
+ bool ForceFork_;
};
- using TBaseFixture = TBaseTestCase;
-
+ using TBaseFixture = TBaseTestCase;
+
// Class for checking that code raises unittest failure
class TUnitTestFailChecker {
public:
@@ -916,12 +916,12 @@ public: \
#define Y_UNIT_TEST_SUITE_IMPL_F(N, T, F) \
namespace NTestSuite##N { \
- class TCurrentTestCase: public F { \
- }; \
+ class TCurrentTestCase: public F { \
+ }; \
class TCurrentTest: public T { \
private: \
- typedef std::function<THolder<NUnitTest::TBaseTestCase>()> TTestCaseFactory; \
- typedef TVector<TTestCaseFactory> TTests; \
+ typedef std::function<THolder<NUnitTest::TBaseTestCase>()> TTestCaseFactory; \
+ typedef TVector<TTestCaseFactory> TTests; \
\
static TTests& Tests() { \
static TTests tests; \
@@ -942,20 +942,20 @@ public: \
Tests().push_back([=]{ return MakeHolder<NUnitTest::TBaseTestCase>(name, body, forceFork); }); \
} \
\
- static void AddTest(TTestCaseFactory testCaseFactory) { \
- Tests().push_back(std::move(testCaseFactory)); \
- } \
- \
+ static void AddTest(TTestCaseFactory testCaseFactory) { \
+ Tests().push_back(std::move(testCaseFactory)); \
+ } \
+ \
virtual void Execute() { \
this->AtStart(); \
- for (TTests::iterator it = Tests().begin(), ie = Tests().end(); it != ie; ++it) { \
- const auto i = (*it)(); \
- if (!this->CheckAccessTest(i->Name_)) { \
+ for (TTests::iterator it = Tests().begin(), ie = Tests().end(); it != ie; ++it) { \
+ const auto i = (*it)(); \
+ if (!this->CheckAccessTest(i->Name_)) { \
continue; \
} \
NUnitTest::TTestContext context(this->TTestBase::Processor()); \
try { \
- this->BeforeTest(i->Name_); \
+ this->BeforeTest(i->Name_); \
{ \
TCleanUp cleaner(this); \
auto testCase = [&i, &context] { \
@@ -967,13 +967,13 @@ public: \
} \
} catch (const ::NUnitTest::TAssertException&) { \
} catch (const yexception& e) { \
- CATCH_REACTION_BT(i->Name_, e, &context); \
+ CATCH_REACTION_BT(i->Name_, e, &context); \
} catch (const std::exception& e) { \
- CATCH_REACTION(i->Name_, e, &context); \
+ CATCH_REACTION(i->Name_, e, &context); \
} catch (...) { \
this->AddError("non-std exception!", &context); \
} \
- this->Finish(i->Name_, &context); \
+ this->Finish(i->Name_, &context); \
} \
this->AtEnd(); \
} \
@@ -988,23 +988,23 @@ public: \
#define RUSAGE_UNIT_TEST_SUITE(N) Y_UNIT_TEST_SUITE_IMPL(N, NUnitTest::TRusageTest, ::NUnitTest::TBaseTestCase)
#define Y_UNIT_TEST_IMPL_REGISTER(N, FF, F) \
- struct TTestCase##N : public F { \
- TTestCase##N() \
- : F() \
- { \
- Name_ = #N; \
- ForceFork_ = FF; \
- } \
- static THolder<NUnitTest::TBaseTestCase> Create() { \
- return ::MakeHolder<TTestCase##N>(); \
- } \
- void Execute_(NUnitTest::TTestContext&) override; \
- }; \
- struct TTestRegistration##N { \
- TTestRegistration##N() { \
- TCurrentTest::AddTest(TTestCase##N::Create); \
- } \
- }; \
+ struct TTestCase##N : public F { \
+ TTestCase##N() \
+ : F() \
+ { \
+ Name_ = #N; \
+ ForceFork_ = FF; \
+ } \
+ static THolder<NUnitTest::TBaseTestCase> Create() { \
+ return ::MakeHolder<TTestCase##N>(); \
+ } \
+ void Execute_(NUnitTest::TTestContext&) override; \
+ }; \
+ struct TTestRegistration##N { \
+ TTestRegistration##N() { \
+ TCurrentTest::AddTest(TTestCase##N::Create); \
+ } \
+ }; \
static const TTestRegistration##N testRegistration##N;
#define Y_UNIT_TEST_IMPL(N, FF, F) \
@@ -1019,10 +1019,10 @@ public: \
namespace NTestSuite##N
#define Y_UNIT_TEST_DECLARE(N) \
- struct TTestCase##N
+ struct TTestCase##N
#define Y_UNIT_TEST_FRIEND(N, T) \
- friend NTestSuite##N::TTestCase##T \
+ friend NTestSuite##N::TTestCase##T \
TString RandomString(size_t len, ui32 seed = 0);
}
diff --git a/library/cpp/testing/unittest/simple.h b/library/cpp/testing/unittest/simple.h
index 7fd97e8d16..2a5300d886 100644
--- a/library/cpp/testing/unittest/simple.h
+++ b/library/cpp/testing/unittest/simple.h
@@ -4,7 +4,7 @@
namespace NUnitTest {
struct TSimpleTestExecutor: public TTestBase {
- typedef TVector<TBaseTestCase> TTests;
+ typedef TVector<TBaseTestCase> TTests;
TTests Tests;
@@ -12,25 +12,25 @@ namespace NUnitTest {
AtStart();
for (typename TTests::iterator i = Tests.begin(), ie = Tests.end(); i != ie; ++i) {
- if (!CheckAccessTest(i->Name_)) {
+ if (!CheckAccessTest(i->Name_)) {
continue;
}
TTestContext context(this->Processor());
try {
- BeforeTest(i->Name_);
+ BeforeTest(i->Name_);
{
TCleanUp cleaner(this);
- TTestBase::Run([i, &context] { i->Body_(context); }, Name(), i->Name_, i->ForceFork_);
+ TTestBase::Run([i, &context] { i->Body_(context); }, Name(), i->Name_, i->ForceFork_);
}
} catch (const ::NUnitTest::TAssertException&) {
} catch (const yexception& e) {
- CATCH_REACTION_BT(i->Name_, e, &context);
+ CATCH_REACTION_BT(i->Name_, e, &context);
} catch (const std::exception& e) {
- CATCH_REACTION(i->Name_, e, &context);
+ CATCH_REACTION(i->Name_, e, &context);
} catch (...) {
AddError("non-std exception!", &context);
}
- Finish(i->Name_, &context);
+ Finish(i->Name_, &context);
}
AtEnd();
diff --git a/library/cpp/testing/unittest/ut/main.cpp b/library/cpp/testing/unittest/ut/main.cpp
index 9057504397..e303e21e30 100644
--- a/library/cpp/testing/unittest/ut/main.cpp
+++ b/library/cpp/testing/unittest/ut/main.cpp
@@ -28,14 +28,14 @@ namespace {
int I;
};
-
- struct TSimpleFixture : public NUnitTest::TBaseFixture {
- size_t Value = 24;
- };
-
- struct TOtherFixture : public NUnitTest::TBaseFixture {
- size_t TheAnswer = 42;
- };
+
+ struct TSimpleFixture : public NUnitTest::TBaseFixture {
+ size_t Value = 24;
+ };
+
+ struct TOtherFixture : public NUnitTest::TBaseFixture {
+ size_t TheAnswer = 42;
+ };
struct TSetUpTearDownFixture : public NUnitTest::TBaseFixture {
int Magic = 3;
@@ -62,27 +62,27 @@ TEST(ETest, Test1) {
}
Y_UNIT_TEST_SUITE(TestSingleTestFixture)
-{
+{
Y_UNIT_TEST_F(Test3, TSimpleFixture) {
- UNIT_ASSERT_EQUAL(Value, 24);
- }
-}
-
+ UNIT_ASSERT_EQUAL(Value, 24);
+ }
+}
+
Y_UNIT_TEST_SUITE_F(TestSuiteFixture, TSimpleFixture)
-{
+{
Y_UNIT_TEST(Test1) {
- UNIT_ASSERT(Value == 24);
- Value = 25;
- }
-
+ UNIT_ASSERT(Value == 24);
+ Value = 25;
+ }
+
Y_UNIT_TEST(Test2) {
- UNIT_ASSERT_EQUAL(Value, 24);
- }
-
+ UNIT_ASSERT_EQUAL(Value, 24);
+ }
+
Y_UNIT_TEST_F(Test3, TOtherFixture) {
- UNIT_ASSERT_EQUAL(TheAnswer, 42);
- }
-}
+ UNIT_ASSERT_EQUAL(TheAnswer, 42);
+ }
+}
Y_UNIT_TEST_SUITE(TestSetUpTearDownFixture)
{