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

Method testIncludeExternC

plugins/clang/tests/test_duchain.cpp:1828–1857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1826}
1827
1828void TestDUChain::testIncludeExternC()
1829{
1830 TestFile header(QStringLiteral("int foo() { return 42; }\n"), QStringLiteral("h"));
1831 // NOTE: header is _not_ explicitly being parsed, instead the impl job does that
1832
1833 const auto code = R"(
1834 extern "C" {
1835 #include "%1"
1836 }
1837 int main() { return foo(); }
1838 )";
1839 TestFile impl(QString::fromUtf8(code).arg(header.url().str()), QStringLiteral("cpp"), &header);
1840 impl.parse(TopDUContext::AllDeclarationsContextsAndUses);
1841 QVERIFY(impl.waitForParsed());
1842
1843 DUChainReadLocker lock;
1844
1845 auto implCtx = impl.topContext();
1846 QVERIFY(implCtx);
1847 QCOMPARE(implCtx->localDeclarations().size(), 1);
1848
1849 auto headerCtx = DUChain::self()->chainForDocument(header.url());
1850 QVERIFY(headerCtx);
1851 QCOMPARE(headerCtx->localDeclarations().size(), 1);
1852 Declaration* foo = headerCtx->localDeclarations().first();
1853 QCOMPARE(foo->uses().size(), 1);
1854 QCOMPARE(foo->uses().begin().key(), impl.url());
1855 QCOMPARE(foo->uses().begin()->size(), 1);
1856 QCOMPARE(foo->uses().begin()->first(), RangeInRevision(4, 28, 4, 31));
1857}
1858
1859void TestDUChain::testReparseUnchanged_data()
1860{

Callers

nothing calls this directly

Calls 13

strMethod · 0.80
waitForParsedMethod · 0.80
localDeclarationsMethod · 0.80
chainForDocumentMethod · 0.80
RangeInRevisionClass · 0.50
urlMethod · 0.45
parseMethod · 0.45
topContextMethod · 0.45
sizeMethod · 0.45
firstMethod · 0.45
usesMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected