2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-08 13:05:33 +03:00
rehlds/dep/cppunitlite/src/Test.cpp

43 lines
832 B
C++
Raw Normal View History

2015-05-04 21:25:41 +03:00
#include "cppunitlite/Test.h"
#include "cppunitlite/TestRegistry.h"
#include "cppunitlite/Failure.h"
#include <exception>
#include <sstream>
Test::Test (const char* testName, const char* testGroup, int timeout)
: name_ (testName), group_ (testGroup), timeout_(timeout)
{
2015-06-27 12:36:55 +03:00
next_ = NULL;
TestRegistry::addTest(this);
2015-05-04 21:25:41 +03:00
}
Test *Test::getNext() const
{
return next_;
}
void Test::setNext(Test *test)
{
next_ = test;
}
void Test::run(TestResult &result) {
try {
runInternal();
} catch (TestFailException &e) {
result.addFailure(Failure(e, name_));
2015-05-04 21:25:41 +03:00
} catch (std::exception &e) {
std::stringstream ss;
ss << "unexpected exception " << e.what();
result.addFailure(Failure(ss.str(), name_));
} catch (...) {
result.addFailure(Failure("unknown exception", name_));
}
}