MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / printTotals

Function printTotals

extlibs/catch/include/catch/catch.hpp:15040–15070  ·  view source on GitHub ↗

Colour, message variants: - white: No tests ran. - red: Failed [both/all] N test cases, failed [both/all] M assertions. - white: Passed [both/all] N test cases (no assertions). - red: Failed N tests cases, failed M assertions. - green: Passed [both/all] N tests cases with M assertions.

Source from the content-addressed store, hash-verified

15038// - red: Failed N tests cases, failed M assertions.
15039// - green: Passed [both/all] N tests cases with M assertions.
15040void printTotals(std::ostream& out, const Totals& totals) {
15041 if (totals.testCases.total() == 0) {
15042 out << "No tests ran.";
15043 } else if (totals.testCases.failed == totals.testCases.total()) {
15044 Colour colour(Colour::ResultError);
15045 const std::string qualify_assertions_failed =
15046 totals.assertions.failed == totals.assertions.total() ?
15047 bothOrAll(totals.assertions.failed) : std::string();
15048 out <<
15049 "Failed " << bothOrAll(totals.testCases.failed)
15050 << pluralise(totals.testCases.failed, "test case") << ", "
15051 "failed " << qualify_assertions_failed <<
15052 pluralise(totals.assertions.failed, "assertion") << '.';
15053 } else if (totals.assertions.total() == 0) {
15054 out <<
15055 "Passed " << bothOrAll(totals.testCases.total())
15056 << pluralise(totals.testCases.total(), "test case")
15057 << " (no assertions).";
15058 } else if (totals.assertions.failed) {
15059 Colour colour(Colour::ResultError);
15060 out <<
15061 "Failed " << pluralise(totals.testCases.failed, "test case") << ", "
15062 "failed " << pluralise(totals.assertions.failed, "assertion") << '.';
15063 } else {
15064 Colour colour(Colour::ResultSuccess);
15065 out <<
15066 "Passed " << bothOrAll(totals.testCases.passed)
15067 << pluralise(totals.testCases.passed, "test case") <<
15068 " with " << pluralise(totals.assertions.passed, "assertion") << '.';
15069 }
15070}
15071
15072// Implementation of CompactReporter formatting
15073class AssertionPrinter {

Callers 2

testRunEndedMethod · 0.85
testGroupEndedMethod · 0.85

Calls 4

bothOrAllFunction · 0.85
pluraliseClass · 0.85
stringClass · 0.50
totalMethod · 0.45

Tested by

no test coverage detected