| 308 | } |
| 309 | |
| 310 | void TestDUChain::testInclude() |
| 311 | { |
| 312 | TestFile header(QStringLiteral("int foo() { return 42; }\n"), QStringLiteral("h")); |
| 313 | // NOTE: header is _not_ explicitly being parsed, instead the impl job does that |
| 314 | |
| 315 | TestFile impl("#include \"" + header.url().str() + "\"\n" |
| 316 | "int main() { return foo(); }", QStringLiteral("cpp"), &header); |
| 317 | impl.parse(TopDUContext::AllDeclarationsContextsAndUses); |
| 318 | |
| 319 | auto implCtx = impl.topContext(); |
| 320 | QVERIFY(implCtx); |
| 321 | |
| 322 | DUChainReadLocker lock; |
| 323 | QCOMPARE(implCtx->localDeclarations().size(), 1); |
| 324 | |
| 325 | auto headerCtx = DUChain::self()->chainForDocument(header.url()); |
| 326 | QVERIFY(headerCtx); |
| 327 | QVERIFY(!headerCtx->parsingEnvironmentFile()->needsUpdate()); |
| 328 | QCOMPARE(headerCtx->localDeclarations().size(), 1); |
| 329 | |
| 330 | QVERIFY(implCtx->imports(headerCtx, CursorInRevision(0, 10))); |
| 331 | |
| 332 | Declaration* foo = headerCtx->localDeclarations().first(); |
| 333 | QCOMPARE(foo->uses().size(), 1); |
| 334 | QCOMPARE(foo->uses().begin().key(), impl.url()); |
| 335 | QCOMPARE(foo->uses().begin()->size(), 1); |
| 336 | QCOMPARE(foo->uses().begin()->first(), RangeInRevision(1, 20, 1, 23)); |
| 337 | } |
| 338 | |
| 339 | void TestDUChain::testMissingInclude() |
| 340 | { |
nothing calls this directly
no test coverage detected