| 266 | } |
| 267 | |
| 268 | void TestResultsTree::testReportType() const |
| 269 | { |
| 270 | TestReport report("{id},{classification},{guideline}"); |
| 271 | |
| 272 | int msgCount = 0; |
| 273 | auto createErrorItem = [&msgCount](const Severity severity, const QString& errorId) -> ErrorItem { |
| 274 | ++msgCount; |
| 275 | ErrorItem errorItem; |
| 276 | errorItem.errorPath << QErrorPathItem(ErrorMessage::FileLocation("file1.c", msgCount, 1)); |
| 277 | errorItem.severity = severity; |
| 278 | errorItem.errorId = errorId; |
| 279 | errorItem.summary = "test summary " + QString::number(msgCount); |
| 280 | return errorItem; |
| 281 | }; |
| 282 | |
| 283 | // normal report with 2 errors |
| 284 | ResultsTree tree(nullptr); |
| 285 | tree.updateSettings(false, false, false, false, false); |
| 286 | tree.addErrorItem(createErrorItem(Severity::style, "id1")); |
| 287 | tree.addErrorItem(createErrorItem(Severity::style, "unusedVariable")); // Misra C 2.8 |
| 288 | tree.saveResults(&report); |
| 289 | QCOMPARE(report.output, "id1,,\nunusedVariable,,"); |
| 290 | |
| 291 | // switch to Misra C report and check that "id1" is not shown |
| 292 | tree.setReportType(ReportType::misraC2012); |
| 293 | tree.saveResults(&report); |
| 294 | QCOMPARE(report.output, "unusedVariable,Advisory,2.8"); |
| 295 | |
| 296 | // add "missingReturn" and check that it is added properly |
| 297 | tree.addErrorItem(createErrorItem(Severity::warning, "missingReturn")); // Misra C 17.4 |
| 298 | tree.saveResults(&report); |
| 299 | QCOMPARE(report.output, |
| 300 | "unusedVariable,Advisory,2.8\n" |
| 301 | "missingReturn,Mandatory,17.4"); |
| 302 | } |
| 303 | |
| 304 | void TestResultsTree::testReportTypeIcon() const { |
| 305 | ResultsTree tree(nullptr); |
nothing calls this directly
no test coverage detected