blob: ebad1ea4d67391d0444855c17ebd38719f89d33e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#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();
}
|