2015-05-04 21:25:41 +03:00
|
|
|
|
|
|
|
#include "cppunitlite/TestResult.h"
|
|
|
|
#include "cppunitlite/Failure.h"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
|
|
TestResult::TestResult ()
|
2015-09-28 16:43:31 +03:00
|
|
|
: failureCount (0), warningCount (0)
|
2015-05-04 21:25:41 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TestResult::testsStarted ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestResult::addFailure (const Failure& failure) {
|
|
|
|
std::stringstream ss;
|
2015-09-28 16:43:31 +03:00
|
|
|
ss << (failure.warning ? "Warning in test '" : "Failure in test '") << failure.testName << "' :" << failure.message;
|
2015-05-04 21:25:41 +03:00
|
|
|
std::cout << ss.str() << std::endl;
|
2015-05-18 16:04:00 +03:00
|
|
|
std::cout.flush();
|
2015-09-28 16:43:31 +03:00
|
|
|
|
|
|
|
if (failure.warning) {
|
|
|
|
warningCount++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
failureCount++;
|
2015-05-04 21:25:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TestResult::testsEnded () {
|
|
|
|
std::stringstream ss;
|
|
|
|
if (failureCount > 0) {
|
|
|
|
ss << "There were " << failureCount << " failures";
|
2015-09-28 16:43:31 +03:00
|
|
|
if (warningCount > 0) {
|
|
|
|
ss << ", and " << warningCount << " warnings";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (warningCount > 0) {
|
|
|
|
ss << "There were " << warningCount << " warnings";
|
|
|
|
}
|
|
|
|
else {
|
2015-05-04 21:25:41 +03:00
|
|
|
ss << "There were no test failures";
|
|
|
|
}
|
2015-09-28 16:43:31 +03:00
|
|
|
|
2015-05-04 21:25:41 +03:00
|
|
|
std::cout << ss.str() << std::endl;
|
2015-05-18 16:04:00 +03:00
|
|
|
std::cout.flush();
|
2015-05-04 21:25:41 +03:00
|
|
|
}
|