| 132 | } |
| 133 | |
| 134 | void TestProblems::testChildDiagnostics() |
| 135 | { |
| 136 | // expected: |
| 137 | // test.cpp:3:14: error: call to 'foo' is ambiguous |
| 138 | // int main() { foo(0); } |
| 139 | // ^~~ |
| 140 | // test.cpp:1:6: note: candidate function |
| 141 | // void foo(unsigned int); |
| 142 | // ^ |
| 143 | // test.cpp:2:6: note: candidate function |
| 144 | // void foo(const char*); |
| 145 | // ^ |
| 146 | const QByteArray code = "void foo(unsigned int);\n" |
| 147 | "void foo(const char*);\n" |
| 148 | "int main() { foo(0); }"; |
| 149 | auto problems = parse(code); |
| 150 | QCOMPARE(problems.size(), 1); |
| 151 | auto range = problems[0]->rangeInCurrentRevision(); |
| 152 | QCOMPARE(range.start(), KTextEditor::Cursor(2, 13)); |
| 153 | QCOMPARE(range.end(), KTextEditor::Cursor(2, 16)); |
| 154 | QCOMPARE(problems[0]->diagnostics().size(), 2); |
| 155 | IProblem::Ptr p1 = problems[0]->diagnostics()[0]; |
| 156 | const ProblemPointer d1 = ProblemPointer(dynamic_cast<Problem*>(p1.data())); |
| 157 | QCOMPARE(d1->url().str(), FileName); |
| 158 | QCOMPARE(d1->rangeInCurrentRevision(), KTextEditor::Range(0, 5, 0, 8)); |
| 159 | IProblem::Ptr p2 = problems[0]->diagnostics()[1]; |
| 160 | const ProblemPointer d2 = ProblemPointer(dynamic_cast<Problem*>(p2.data())); |
| 161 | QCOMPARE(d2->url().str(), FileName); |
| 162 | QCOMPARE(d2->rangeInCurrentRevision(), KTextEditor::Range(1, 5, 1, 8)); |
| 163 | } |
| 164 | |
| 165 | Q_DECLARE_METATYPE(QVector<ClangFixit>) |
| 166 | |