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.
| 15863 | // - red: Failed N tests cases, failed M assertions. |
| 15864 | // - green: Passed [both/all] N tests cases with M assertions. |
| 15865 | void printTotals(std::ostream& out, const Totals& totals) { |
| 15866 | if (totals.testCases.total() == 0) { |
| 15867 | out << "No tests ran."; |
| 15868 | } else if (totals.testCases.failed == totals.testCases.total()) { |
| 15869 | Colour colour(Colour::ResultError); |
| 15870 | const std::string qualify_assertions_failed = |
| 15871 | totals.assertions.failed == totals.assertions.total() ? |
| 15872 | bothOrAll(totals.assertions.failed) : std::string(); |
| 15873 | out << |
| 15874 | "Failed " << bothOrAll(totals.testCases.failed) |
| 15875 | << pluralise(totals.testCases.failed, "test case") << ", " |
| 15876 | "failed " << qualify_assertions_failed << |
| 15877 | pluralise(totals.assertions.failed, "assertion") << '.'; |
| 15878 | } else if (totals.assertions.total() == 0) { |
| 15879 | out << |
| 15880 | "Passed " << bothOrAll(totals.testCases.total()) |
| 15881 | << pluralise(totals.testCases.total(), "test case") |
| 15882 | << " (no assertions)."; |
| 15883 | } else if (totals.assertions.failed) { |
| 15884 | Colour colour(Colour::ResultError); |
| 15885 | out << |
| 15886 | "Failed " << pluralise(totals.testCases.failed, "test case") << ", " |
| 15887 | "failed " << pluralise(totals.assertions.failed, "assertion") << '.'; |
| 15888 | } else { |
| 15889 | Colour colour(Colour::ResultSuccess); |
| 15890 | out << |
| 15891 | "Passed " << bothOrAll(totals.testCases.passed) |
| 15892 | << pluralise(totals.testCases.passed, "test case") << |
| 15893 | " with " << pluralise(totals.assertions.passed, "assertion") << '.'; |
| 15894 | } |
| 15895 | } |
| 15896 | |
| 15897 | // Implementation of CompactReporter formatting |
| 15898 | class AssertionPrinter { |
no test coverage detected