diff options
author | Mikhail Borisov <borisov.mikhail@gmail.com> | 2022-02-10 16:45:40 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:40 +0300 |
commit | 5d50718e66d9c037dc587a0211110b7d25a66185 (patch) | |
tree | e98df59de24d2ef7c77baed9f41e4875a2fef972 /library/cpp/testing | |
parent | a6a92afe03e02795227d2641b49819b687f088f8 (diff) | |
download | ydb-5d50718e66d9c037dc587a0211110b7d25a66185.tar.gz |
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing')
-rw-r--r-- | library/cpp/testing/common/env.cpp | 36 | ||||
-rw-r--r-- | library/cpp/testing/unittest/registar.h | 54 | ||||
-rw-r--r-- | library/cpp/testing/unittest/ut/main.cpp | 44 |
3 files changed, 67 insertions, 67 deletions
diff --git a/library/cpp/testing/common/env.cpp b/library/cpp/testing/common/env.cpp index fc70e0f5b9..fa3a47fe16 100644 --- a/library/cpp/testing/common/env.cpp +++ b/library/cpp/testing/common/env.cpp @@ -1,7 +1,7 @@ #include "env.h" -#include <build/scripts/c_templates/svnversion.h> - +#include <build/scripts/c_templates/svnversion.h> + #include <util/folder/dirut.h> #include <util/folder/path.h> #include <util/generic/singleton.h> @@ -16,22 +16,22 @@ #include <library/cpp/json/json_value.h> #include <library/cpp/json/json_writer.h> -TString ArcadiaSourceRoot() { - if (const auto& sourceRoot = NPrivate::GetTestEnv().SourceRoot) { - return sourceRoot; - } else { - return GetArcadiaSourcePath(); - } -} - -TString BuildRoot() { - if (const auto& buildRoot = NPrivate::GetTestEnv().BuildRoot) { - return buildRoot; - } else { - return GetArcadiaSourcePath(); - } -} - +TString ArcadiaSourceRoot() { + if (const auto& sourceRoot = NPrivate::GetTestEnv().SourceRoot) { + return sourceRoot; + } else { + return GetArcadiaSourcePath(); + } +} + +TString BuildRoot() { + if (const auto& buildRoot = NPrivate::GetTestEnv().BuildRoot) { + return buildRoot; + } else { + return GetArcadiaSourcePath(); + } +} + TString ArcadiaFromCurrentLocation(TStringBuf where, TStringBuf path) { return (TFsPath(ArcadiaSourceRoot()) / TFsPath(where).Parent() / path).Fix(); } 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; + } +} |