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

Method multiLineResult

gui/test/resultstree/testresultstree.cpp:180–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180void TestResultsTree::multiLineResult() const
181{
182 // Create tree with 1 multiline message
183 ResultsTree tree(nullptr);
184 ErrorItem errorItem = createErrorItem("file1.c", 10, Severity::style, "test", "bugId");
185 errorItem.errorPath << createErrorPathItem("file2.c", 23, 2, "abc");
186 tree.addErrorItem(errorItem);
187
188 // Verify model
189 const auto* model = dynamic_cast<QStandardItemModel*>(tree.model());
190 QVERIFY(model != nullptr);
191 QVERIFY(model->rowCount() == 1);
192
193 // Verify file item
194 const ResultItem* fileItem = dynamic_cast<ResultItem*>(model->item(0,0));
195 QVERIFY(fileItem != nullptr);
196 QCOMPARE(fileItem->getType(), ResultItem::Type::file);
197 QCOMPARE(fileItem->text(), "file2.c");
198 QCOMPARE(fileItem->getErrorPathItem().file, "file2.c");
199 QVERIFY(fileItem->rowCount() == 1);
200
201 // Verify message item
202 const ResultItem* res = dynamic_cast<ResultItem*>(fileItem->child(0,0));
203 QVERIFY(res != nullptr);
204 QCOMPARE(res->text(), "file2.c");
205 QVERIFY(res->errorItem != nullptr);
206 QCOMPARE(res->errorItem->toString(),
207 "file2.c:23:2:style: test [bugId]\n"
208 "file1.c:10:1:note: test\n"
209 "file2.c:23:2:note: abc");
210 QCOMPARE(res->getErrorPathItem().file, "file2.c");
211 QVERIFY(res->rowCount() == 2);
212 QVERIFY(res->columnCount() > 5);
213 // Verify both notes
214 for (int row = 0; row < 2; ++row) {
215 for (int col = 0; col < res->columnCount(); ++col) {
216 const ResultItem* item = dynamic_cast<ResultItem*>(res->child(row,col));
217 QVERIFY(item);
218 QCOMPARE(item->errorItem.get(), res->errorItem.get());
219 QCOMPARE(item->getType(), ResultItem::Type::note);
220 QCOMPARE(item->getErrorPathItem().file, row == 0 ? "file1.c" : "file2.c");
221 }
222 }
223}
224
225void TestResultsTree::resultsInSameFile() const
226{

Callers

nothing calls this directly

Calls 8

createErrorItemFunction · 0.85
createErrorPathItemFunction · 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