/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
library/cpp/testing/unittest/gtest.cpp
67 строк
1 KB
qkrorlqr
Initial NBS OpenSource export
28 апр 2023, 21:54
28 апр 2023, 21:54
783a858
Код
Авторство
О чём код?
#include "gtest.h" #include "simple.h" #include <util/generic/map.h> #include <util/generic/vector.h> #include <util/system/type_name.h> using namespace NUnitTest; using namespace NUnitTest::NPrivate; IGTestFactory::~IGTestFactory() { } namespace { struct TCurrentTest: public TSimpleTestExecutor { inline TCurrentTest(TStringBuf name) : MyName(name) { } TString TypeId() const override { return TypeName(*this) + "-" + MyName; } TString Name() const noexcept override { return TString(MyName); } const TStringBuf MyName; }; struct TGTestFactory: public IGTestFactory { inline TGTestFactory(TStringBuf name) : Test(name) { } ~TGTestFactory() override { } TString Name() const noexcept override { return Test.Name(); } TTestBase* ConstructTest() override { return new TCurrentTest(Test); } void AddTest(const char* name, void (*body)(TTestContext&), bool forceFork) override { Test.Tests.push_back(TBaseTestCase(name, body, forceFork)); } TCurrentTest Test; }; } IGTestFactory* NUnitTest::NPrivate::ByName(const char* name) { static TMap<TStringBuf, TAutoPtr<TGTestFactory>> tests; auto& ret = tests[name]; if (!ret) { ret = new TGTestFactory(name); } return ret.Get(); }