MCPcopy Create free account
hub / github.com/KDE/kdevelop / testInclude

Method testInclude

plugins/clang/tests/test_duchain.cpp:310–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310void 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
339void TestDUChain::testMissingInclude()
340{

Callers

nothing calls this directly

Calls 15

strMethod · 0.80
localDeclarationsMethod · 0.80
chainForDocumentMethod · 0.80
CursorInRevisionClass · 0.50
RangeInRevisionClass · 0.50
urlMethod · 0.45
parseMethod · 0.45
topContextMethod · 0.45
sizeMethod · 0.45
needsUpdateMethod · 0.45
importsMethod · 0.45

Tested by

no test coverage detected