blob: 7c59b08315a8e70c86e757c26b4eda82d130760c (
plain)
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
|
#pragma once
#include <functional>
#include <utility>
class TestRegister
{
public:
TestRegister(char const * testname, char const * filename, std::function<void()> && fnTest)
: m_testname(testname), m_filename(filename), m_fn(std::move(fnTest)), m_next(nullptr)
{
if (FirstRegister() == nullptr)
{
FirstRegister() = this;
}
else
{
TestRegister * last = FirstRegister();
while (last->m_next != nullptr)
last = last->m_next;
last->m_next = this;
}
}
static TestRegister *& FirstRegister()
{
static TestRegister * test = nullptr;
return test;
}
// Test name.
char const * m_testname;
// File name.
char const * m_filename;
// Function to run test.
std::function<void()> m_fn;
// Next test in chain.
TestRegister * m_next;
};
|