MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / resultsInSameFile

Method resultsInSameFile

gui/test/resultstree/testresultstree.cpp:225–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225void TestResultsTree::resultsInSameFile() const
226{
227 ResultsTree tree(nullptr);
228 tree.addErrorItem(createErrorItem("file1.c", 10, Severity::style, "test", "bugId"));
229 tree.addErrorItem(createErrorItem("file1.c", 20, Severity::style, "test", "bugId"));
230 const auto* model = dynamic_cast<QStandardItemModel*>(tree.model());
231 QVERIFY(model != nullptr);
232 QVERIFY(model->rowCount() == 1);
233
234 const ResultItem* fileItem = dynamic_cast<ResultItem*>(model->item(0,0));
235 QVERIFY(fileItem != nullptr);
236 QCOMPARE(fileItem->getType(), ResultItem::Type::file);
237 QCOMPARE(fileItem->text(), "file1.c");
238 QCOMPARE(fileItem->getErrorPathItem().file, "file1.c");
239 QVERIFY(fileItem->rowCount() == 2);
240
241 const ResultItem* res1 = dynamic_cast<ResultItem*>(fileItem->child(0,0));
242 QVERIFY(res1 != nullptr);
243 QCOMPARE(res1->text(), "file1.c");
244 QVERIFY(res1->errorItem != nullptr);
245 QCOMPARE(res1->errorItem->toString(), "file1.c:10:1:style: test [bugId]");
246 QVERIFY(res1->rowCount() == 0);
247 for (int col = 0; col < fileItem->columnCount(); ++col) {
248 const ResultItem* item = dynamic_cast<ResultItem*>(fileItem->child(0,col));
249 QVERIFY(item);
250 QCOMPARE(item->errorItem.get(), res1->errorItem.get());
251 QCOMPARE(item->getType(), ResultItem::Type::message);
252 }
253
254 const ResultItem* res2 = dynamic_cast<ResultItem*>(fileItem->child(1,0));
255 QVERIFY(res2 != nullptr);
256 QCOMPARE(res2->text(), "file1.c");
257 QVERIFY(res2->errorItem != nullptr);
258 QCOMPARE(res2->errorItem->toString(), "file1.c:20:1:style: test [bugId]");
259 QVERIFY(res2->rowCount() == 0);
260 for (int col = 0; col < fileItem->columnCount(); ++col) {
261 const ResultItem* item = dynamic_cast<ResultItem*>(fileItem->child(1,col));
262 QVERIFY(item);
263 QCOMPARE(item->errorItem.get(), res2->errorItem.get());
264 QCOMPARE(item->getType(), ResultItem::Type::message);
265 }
266}
267
268void TestResultsTree::testReportType() const
269{

Callers

nothing calls this directly

Calls 7

createErrorItemFunction · 0.85
addErrorItemMethod · 0.80
rowCountMethod · 0.80
getErrorPathItemMethod · 0.80
getTypeMethod · 0.45
toStringMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected