@@ -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+
158197void TestResultsTree::resultsInSameFile () const
159198{
160199 ResultsTree tree (nullptr );
0 commit comments