ReGameDLL_CS/dep/cppunitlite/src/TestResult.cpp

49 lines
952 B
C++
Raw Normal View History

2019-09-23 00:09:58 +03:00
#include "cppunitlite/TestResult.h"
#include "cppunitlite/Failure.h"
#include <sstream>
#include <iostream>
2021-04-12 17:51:51 +03:00
TestResult::TestResult()
: failureCount(0), warningCount(0)
2019-09-23 00:09:58 +03:00
{
}
2021-04-12 17:51:51 +03:00
void TestResult::testsStarted()
2019-09-23 00:09:58 +03:00
{
}
2021-04-12 17:51:51 +03:00
void TestResult::addFailure(const Failure& failure)
{
2019-09-23 00:09:58 +03:00
std::stringstream ss;
2021-04-12 17:51:51 +03:00
ss << (failure.warning ? "Warning in test '" : "Failure in test '") << failure.testName << "' :" << failure.message;
2019-09-23 00:09:58 +03:00
std::cout << ss.str() << std::endl;
std::cout.flush();
2021-04-12 17:51:51 +03:00
if (failure.warning) {
warningCount++;
}
else
failureCount++;
}
2019-09-23 00:09:58 +03:00
2021-04-12 17:51:51 +03:00
void TestResult::testsEnded()
{
2019-09-23 00:09:58 +03:00
std::stringstream ss;
if (failureCount > 0) {
ss << "There were " << failureCount << " failures";
2021-04-12 17:51:51 +03:00
if (warningCount > 0) {
ss << ", and " << warningCount << " warnings";
}
}
else if (warningCount > 0) {
ss << "There were " << warningCount << " warnings";
}
else {
2019-09-23 00:09:58 +03:00
ss << "There were no test failures";
}
2021-04-12 17:51:51 +03:00
2019-09-23 00:09:58 +03:00
std::cout << ss.str() << std::endl;
std::cout.flush();
}