ReGameDLL_CS/dep/cppunitlite/src/TestRegistry.cpp

45 lines
711 B
C++
Raw Normal View History

2019-09-23 00:09:58 +03:00
#include "cppunitlite/Test.h"
#include "cppunitlite/TestResult.h"
#include "cppunitlite/TestRegistry.h"
2021-04-12 17:51:51 +03:00
void TestRegistry::addTest(Test *test)
2019-09-23 00:09:58 +03:00
{
2021-04-12 17:51:51 +03:00
instance().add(test);
2019-09-23 00:09:58 +03:00
}
2021-04-12 17:51:51 +03:00
void TestRegistry::runAllTests(TestResult &result)
2019-09-23 00:09:58 +03:00
{
2021-04-12 17:51:51 +03:00
instance().run(result);
2019-09-23 00:09:58 +03:00
}
2021-04-12 17:51:51 +03:00
Test *TestRegistry::getFirstTest() {
2019-09-23 00:09:58 +03:00
return instance().tests;
}
2021-04-12 17:51:51 +03:00
TestRegistry& TestRegistry::instance()
2019-09-23 00:09:58 +03:00
{
static TestRegistry registry;
return registry;
}
2021-04-12 17:51:51 +03:00
void TestRegistry::add(Test *test)
2019-09-23 00:09:58 +03:00
{
if (tests == 0) {
tests = test;
return;
}
2021-04-12 17:51:51 +03:00
test->setNext(tests);
2019-09-23 00:09:58 +03:00
tests = test;
}
2021-04-12 17:51:51 +03:00
void TestRegistry::run(TestResult &result)
2019-09-23 00:09:58 +03:00
{
2021-04-12 17:51:51 +03:00
result.testsStarted();
2019-09-23 00:09:58 +03:00
2021-04-12 17:51:51 +03:00
for (Test *test = tests; test; test = test->getNext())
test->run(result);
2019-09-23 00:09:58 +03:00
2021-04-12 17:51:51 +03:00
result.testsEnded();
}