Skip to content

Commit 0bd361c

Browse files
committed
test multiLineResult
1 parent f6601c5 commit 0bd361c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

gui/test/resultstree/testresultstree.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,45 @@ static ErrorItem createErrorItem(QString file, int line, Severity sev, QString m
155155
return ret;
156156
}
157157

158+
void TestResultsTree::multiLineResult() const
159+
{
160+
ResultsTree tree(nullptr);
161+
ErrorItem errorItem = createErrorItem("file1.c", 10, Severity::style, "test", "bugId");
162+
errorItem.errorPath << createErrorPathItem("file2.c", 23, 2, "abc");
163+
tree.addErrorItem(errorItem);
164+
QStandardItemModel* model = dynamic_cast<QStandardItemModel*>(tree.model());
165+
QVERIFY(model != nullptr);
166+
QVERIFY(model->rowCount() == 1);
167+
168+
const ResultItem* fileItem = dynamic_cast<ResultItem*>(model->item(0,0));
169+
QVERIFY(fileItem != nullptr);
170+
QCOMPARE(fileItem->getType(), ResultItem::Type::file);
171+
QCOMPARE(fileItem->text(), "file2.c");
172+
QCOMPARE(fileItem->getErrorPathItem().file, "file2.c");
173+
QVERIFY(fileItem->rowCount() == 1);
174+
175+
const ResultItem* res = dynamic_cast<ResultItem*>(fileItem->child(0,0));
176+
QVERIFY(res != nullptr);
177+
QCOMPARE(res->text(), "file2.c");
178+
QVERIFY(res->errorItem != nullptr);
179+
QCOMPARE(res->errorItem->toString(),
180+
"file2.c:23:2:style: test [bugId]\n"
181+
"file1.c:10:1:note: test\n"
182+
"file2.c:23:2:note: abc");
183+
QCOMPARE(res->getErrorPathItem().file, "file2.c");
184+
QVERIFY(res->rowCount() == 2);
185+
QVERIFY(res->columnCount() > 5);
186+
for (int row = 0; row < 2; ++row) {
187+
for (int col = 0; col < res->columnCount(); ++col) {
188+
const ResultItem* item = dynamic_cast<ResultItem*>(res->child(row,col));
189+
QVERIFY(item);
190+
QCOMPARE(item->errorItem.get(), res->errorItem.get());
191+
QCOMPARE(item->getType(), ResultItem::Type::note);
192+
QCOMPARE(item->getErrorPathItem().file, row == 0 ? "file1.c" : "file2.c");
193+
}
194+
}
195+
}
196+
158197
void TestResultsTree::resultsInSameFile() const
159198
{
160199
ResultsTree tree(nullptr);

gui/test/resultstree/testresultstree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TestResultsTree : public QObject {
2323

2424
private slots:
2525
void test1() const;
26+
void multiLineResult() const;
2627
void resultsInSameFile() const;
2728
void testReportType() const;
2829
void testGetGuidelineError() const;

0 commit comments

Comments
 (0)