| 151 | } |
| 152 | |
| 153 | void TestResult::printFailure(bool printTestName) const { |
| 154 | if (failures_.empty()) { |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | if (printTestName) { |
| 159 | printf("* Detail of %s test failure:\n", name_.c_str()); |
| 160 | } |
| 161 | |
| 162 | // Print in reverse to display the callstack in the right order |
| 163 | Failures::const_iterator itEnd = failures_.end(); |
| 164 | for (Failures::const_iterator it = failures_.begin(); it != itEnd; ++it) { |
| 165 | const Failure& failure = *it; |
| 166 | JSONCPP_STRING indent(failure.nestingLevel_ * 2, ' '); |
| 167 | if (failure.file_) { |
| 168 | printf("%s%s(%d): ", indent.c_str(), failure.file_, failure.line_); |
| 169 | } |
| 170 | if (!failure.expr_.empty()) { |
| 171 | printf("%s\n", failure.expr_.c_str()); |
| 172 | } else if (failure.file_) { |
| 173 | printf("\n"); |
| 174 | } |
| 175 | if (!failure.message_.empty()) { |
| 176 | JSONCPP_STRING reindented = indentText(failure.message_, indent + " "); |
| 177 | printf("%s\n", reindented.c_str()); |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | JSONCPP_STRING TestResult::indentText(const JSONCPP_STRING& text, |
| 183 | const JSONCPP_STRING& indent) { |
no test coverage detected