@@ -303,5 +303,50 @@ void TestResultsTree::testGetGuidelineError() const
303303 QCOMPARE (report.output , " id1,Required,1.3" );
304304}
305305
306+ void TestResultsTree::misraCReportShowClassifications () const
307+ {
308+ ResultsTree tree (nullptr );
309+ tree.showResults (ShowTypes::ShowType::ShowErrors, true );
310+ tree.showResults (ShowTypes::ShowType::ShowWarnings, true );
311+ tree.showResults (ShowTypes::ShowType::ShowStyle, true );
312+ tree.setReportType (ReportType::misraC2012);
313+ tree.addErrorItem (createErrorItem (" file1.c" , 10 , Severity::style, " some rule text" , " premium-misra-c-2012-1.1" )); // Required
314+ tree.addErrorItem (createErrorItem (" file1.c" , 20 , Severity::style, " some rule text" , " premium-misra-c-2012-1.2" )); // Advisory
315+ tree.addErrorItem (createErrorItem (" file1.c" , 30 , Severity::style, " some rule text" , " premium-misra-c-2012-9.1" )); // Mandatory
316+ QCOMPARE (tree.isRowHidden (0 , QModelIndex ()), false );
317+
318+ const auto * model = dynamic_cast <QStandardItemModel*>(tree.model ());
319+ QVERIFY (model != nullptr );
320+ QVERIFY (model->rowCount () == 1 );
321+ const ResultItem* fileItem = dynamic_cast <ResultItem*>(model->item (0 ,0 ));
322+ QVERIFY (fileItem != nullptr );
323+ QVERIFY (fileItem->rowCount () == 3 );
324+
325+ QCOMPARE (tree.isRowHidden (0 , fileItem->index ()), false );
326+ QCOMPARE (tree.isRowHidden (1 , fileItem->index ()), false );
327+ QCOMPARE (tree.isRowHidden (2 , fileItem->index ()), false );
328+
329+ tree.showResults (ShowTypes::ShowType::ShowErrors, false );
330+ tree.showResults (ShowTypes::ShowType::ShowWarnings, true );
331+ tree.showResults (ShowTypes::ShowType::ShowStyle, true );
332+ QCOMPARE (tree.isRowHidden (0 , fileItem->index ()), false );
333+ QCOMPARE (tree.isRowHidden (1 , fileItem->index ()), false );
334+ QCOMPARE (tree.isRowHidden (2 , fileItem->index ()), true );
335+
336+ tree.showResults (ShowTypes::ShowType::ShowErrors, true );
337+ tree.showResults (ShowTypes::ShowType::ShowWarnings, false );
338+ tree.showResults (ShowTypes::ShowType::ShowStyle, true );
339+ QCOMPARE (tree.isRowHidden (0 , fileItem->index ()), true );
340+ QCOMPARE (tree.isRowHidden (1 , fileItem->index ()), false );
341+ QCOMPARE (tree.isRowHidden (2 , fileItem->index ()), false );
342+
343+ tree.showResults (ShowTypes::ShowType::ShowErrors, true );
344+ tree.showResults (ShowTypes::ShowType::ShowWarnings, true );
345+ tree.showResults (ShowTypes::ShowType::ShowStyle, false );
346+ QCOMPARE (tree.isRowHidden (0 , fileItem->index ()), false );
347+ QCOMPARE (tree.isRowHidden (1 , fileItem->index ()), true );
348+ QCOMPARE (tree.isRowHidden (2 , fileItem->index ()), false );
349+ }
350+
306351QTEST_MAIN (TestResultsTree)
307352
0 commit comments