Formatter impl for ConsoleReporter
| 13101 | |
| 13102 | // Formatter impl for ConsoleReporter |
| 13103 | class ConsoleAssertionPrinter { |
| 13104 | public: |
| 13105 | ConsoleAssertionPrinter& operator= (ConsoleAssertionPrinter const&) = delete; |
| 13106 | ConsoleAssertionPrinter(ConsoleAssertionPrinter const&) = delete; |
| 13107 | ConsoleAssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages) |
| 13108 | : stream(_stream), |
| 13109 | stats(_stats), |
| 13110 | result(_stats.assertionResult), |
| 13111 | colour(Colour::None), |
| 13112 | message(result.getMessage()), |
| 13113 | messages(_stats.infoMessages), |
| 13114 | printInfoMessages(_printInfoMessages) { |
| 13115 | switch (result.getResultType()) { |
| 13116 | case ResultWas::Ok: |
| 13117 | colour = Colour::Success; |
| 13118 | passOrFail = "PASSED"; |
| 13119 | //if( result.hasMessage() ) |
| 13120 | if (_stats.infoMessages.size() == 1) |
| 13121 | messageLabel = "with message"; |
| 13122 | if (_stats.infoMessages.size() > 1) |
| 13123 | messageLabel = "with messages"; |
| 13124 | break; |
| 13125 | case ResultWas::ExpressionFailed: |
| 13126 | if (result.isOk()) { |
| 13127 | colour = Colour::Success; |
| 13128 | passOrFail = "FAILED - but was ok"; |
| 13129 | } else { |
| 13130 | colour = Colour::Error; |
| 13131 | passOrFail = "FAILED"; |
| 13132 | } |
| 13133 | if (_stats.infoMessages.size() == 1) |
| 13134 | messageLabel = "with message"; |
| 13135 | if (_stats.infoMessages.size() > 1) |
| 13136 | messageLabel = "with messages"; |
| 13137 | break; |
| 13138 | case ResultWas::ThrewException: |
| 13139 | colour = Colour::Error; |
| 13140 | passOrFail = "FAILED"; |
| 13141 | messageLabel = "due to unexpected exception with "; |
| 13142 | if (_stats.infoMessages.size() == 1) |
| 13143 | messageLabel += "message"; |
| 13144 | if (_stats.infoMessages.size() > 1) |
| 13145 | messageLabel += "messages"; |
| 13146 | break; |
| 13147 | case ResultWas::FatalErrorCondition: |
| 13148 | colour = Colour::Error; |
| 13149 | passOrFail = "FAILED"; |
| 13150 | messageLabel = "due to a fatal error condition"; |
| 13151 | break; |
| 13152 | case ResultWas::DidntThrowException: |
| 13153 | colour = Colour::Error; |
| 13154 | passOrFail = "FAILED"; |
| 13155 | messageLabel = "because no exception was thrown where one was expected"; |
| 13156 | break; |
| 13157 | case ResultWas::Info: |
| 13158 | messageLabel = "info"; |
| 13159 | break; |
| 13160 | case ResultWas::Warning: |
nothing calls this directly
no outgoing calls
no test coverage detected