feat: add testrunner and test interface

This commit is contained in:
2026-05-07 01:17:51 -03:00
parent b2fa9f3351
commit e0887dd149
+56
View File
@@ -0,0 +1,56 @@
#pragma once
#include <vector>
/*
test implementation interface
*/
class ITest
{
public:
ITest();
virtual ~ITest() = default;
protected:
virtual void run() = 0;
friend class TestRunner;
};
/*
test runner singleton class
*/
class TestRunner
{
public:
void runTests()
{
for (auto& test : _tests)
test->run();
}
static TestRunner& get()
{
static TestRunner instance;
return instance;
}
protected:
void registerTest(ITest* test) { _tests.push_back(test); }
friend class ITest;
private:
TestRunner();
TestRunner(const TestRunner&) = delete;
TestRunner& operator=(const TestRunner&) = delete;
std::vector<ITest*> _tests;
};
/*
test cctor
*/
inline ITest::ITest()
{
TestRunner::get().registerTest(this);
}