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