| 141 | bool TestResult::failed() const { return !failures_.empty(); } |
| 142 | |
| 143 | void TestResult::printFailure(bool printTestName) const { |
| 144 | if (failures_.empty()) { |
| 145 | return; |
| 146 | } |
| 147 | |
| 148 | if (printTestName) { |
| 149 | printf("* Detail of %s test failure:\n", name_.c_str()); |
| 150 | } |
| 151 | |
| 152 | // Print in reverse to display the callstack in the right order |
| 153 | for (const auto & failure : failures_ ) { |
| 154 | JSONCPP_STRING indent(failure.nestingLevel_ * 2, ' '); |
| 155 | if (failure.file_) { |
| 156 | printf("%s%s(%u): ", indent.c_str(), failure.file_, failure.line_); |
| 157 | } |
| 158 | if (!failure.expr_.empty()) { |
| 159 | printf("%s\n", failure.expr_.c_str()); |
| 160 | } else if (failure.file_) { |
| 161 | printf("\n"); |
| 162 | } |
| 163 | if (!failure.message_.empty()) { |
| 164 | JSONCPP_STRING reindented = indentText(failure.message_, indent + " "); |
| 165 | printf("%s\n", reindented.c_str()); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | JSONCPP_STRING TestResult::indentText(const JSONCPP_STRING& text, |
| 171 | const JSONCPP_STRING& indent) { |
no test coverage detected