aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/testing/unittest
diff options
context:
space:
mode:
authorMikhail Borisov <borisov.mikhail@gmail.com>2022-02-10 16:45:40 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:40 +0300
commit5d50718e66d9c037dc587a0211110b7d25a66185 (patch)
treee98df59de24d2ef7c77baed9f41e4875a2fef972 /library/cpp/testing/unittest
parenta6a92afe03e02795227d2641b49819b687f088f8 (diff)
downloadydb-5d50718e66d9c037dc587a0211110b7d25a66185.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing/unittest')
-rw-r--r--library/cpp/testing/unittest/registar.h54
-rw-r--r--library/cpp/testing/unittest/ut/main.cpp44
2 files changed, 49 insertions, 49 deletions
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h
index 05facde717..44517a0092 100644
--- a/library/cpp/testing/unittest/registar.h
+++ b/library/cpp/testing/unittest/registar.h
@@ -561,7 +561,7 @@ public: \
} \
} while (false)
-#define UNIT_CHECK_GENERATED_NO_EXCEPTION(A, E) UNIT_CHECK_GENERATED_NO_EXCEPTION_C(A, E, "and exception message is:\n" << CurrentExceptionMessage())
+#define UNIT_CHECK_GENERATED_NO_EXCEPTION(A, E) UNIT_CHECK_GENERATED_NO_EXCEPTION_C(A, E, "and exception message is:\n" << CurrentExceptionMessage())
// Same as UNIT_ASSERT_EXCEPTION_SATISFIES but prints additional string C when nothing was thrown
#define UNIT_ASSERT_EXCEPTION_SATISFIES_C(A, E, pred, C) \
@@ -795,11 +795,11 @@ public: \
};
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
-
+ // 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)
{
@@ -814,21 +814,21 @@ public: \
virtual ~TBaseTestCase() = default;
- // Each test case is executed in 3 steps:
- //
- // 1. SetUp() (from fixture)
- // 2. Execute_() (test body from Y_UNIT_TEST macro)
- // 3. TearDown() (from fixture)
- //
- // 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 */) {
- }
-
+ // Each test case is executed in 3 steps:
+ //
+ // 1. SetUp() (from fixture)
+ // 2. Execute_() (test body from Y_UNIT_TEST macro)
+ // 3. TearDown() (from fixture)
+ //
+ // 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);
}
@@ -958,12 +958,12 @@ public: \
this->BeforeTest(i->Name_); \
{ \
TCleanUp cleaner(this); \
- auto testCase = [&i, &context] { \
- i->SetUp(context); \
- i->Execute_(context); \
- i->TearDown(context); \
- }; \
- this->T::Run(testCase, StaticName(), i->Name_, i->ForceFork_); \
+ auto testCase = [&i, &context] { \
+ i->SetUp(context); \
+ i->Execute_(context); \
+ i->TearDown(context); \
+ }; \
+ this->T::Run(testCase, StaticName(), i->Name_, i->ForceFork_); \
} \
} catch (const ::NUnitTest::TAssertException&) { \
} catch (const yexception& e) { \
diff --git a/library/cpp/testing/unittest/ut/main.cpp b/library/cpp/testing/unittest/ut/main.cpp
index e80326adf1..e303e21e30 100644
--- a/library/cpp/testing/unittest/ut/main.cpp
+++ b/library/cpp/testing/unittest/ut/main.cpp
@@ -36,20 +36,20 @@ namespace {
struct TOtherFixture : public NUnitTest::TBaseFixture {
size_t TheAnswer = 42;
};
-
- struct TSetUpTearDownFixture : public NUnitTest::TBaseFixture {
- int Magic = 3;
-
- void SetUp(NUnitTest::TTestContext&) override {
- UNIT_ASSERT_VALUES_EQUAL(Magic, 3);
- Magic = 17;
- }
-
- void TearDown(NUnitTest::TTestContext&) override {
- UNIT_ASSERT_VALUES_EQUAL(Magic, 42);
- Magic = 100;
- }
- };
+
+ struct TSetUpTearDownFixture : public NUnitTest::TBaseFixture {
+ int Magic = 3;
+
+ void SetUp(NUnitTest::TTestContext&) override {
+ UNIT_ASSERT_VALUES_EQUAL(Magic, 3);
+ Magic = 17;
+ }
+
+ void TearDown(NUnitTest::TTestContext&) override {
+ UNIT_ASSERT_VALUES_EQUAL(Magic, 42);
+ Magic = 100;
+ }
+ };
}
TEST_F(TFixture, Test1) {
@@ -83,11 +83,11 @@ Y_UNIT_TEST_SUITE_F(TestSuiteFixture, TSimpleFixture)
UNIT_ASSERT_EQUAL(TheAnswer, 42);
}
}
-
-Y_UNIT_TEST_SUITE(TestSetUpTearDownFixture)
-{
- Y_UNIT_TEST_F(Test1, TSetUpTearDownFixture) {
- UNIT_ASSERT_VALUES_EQUAL(Magic, 17);
- Magic = 42;
- }
-}
+
+Y_UNIT_TEST_SUITE(TestSetUpTearDownFixture)
+{
+ Y_UNIT_TEST_F(Test1, TSetUpTearDownFixture) {
+ UNIT_ASSERT_VALUES_EQUAL(Magic, 17);
+ Magic = 42;
+ }
+}