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

Method testTemplate

plugins/clang/tests/test_duchain.cpp:513–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511}
512
513void TestDUChain::testTemplate()
514{
515 TestFile file("template<typename T> struct foo { T bar; };\n"
516 "int main() { foo<int> myFoo; return myFoo.bar; }\n", QStringLiteral("cpp"));
517 QVERIFY(file.parseAndWait());
518
519 DUChainReadLocker lock;
520 QVERIFY(file.topContext());
521 QCOMPARE(file.topContext()->localDeclarations().size(), 2);
522 auto fooDecl = file.topContext()->localDeclarations().first();
523 QVERIFY(fooDecl->internalContext());
524 QCOMPARE(fooDecl->internalContext()->localDeclarations().size(), 2);
525
526 QCOMPARE(file.topContext()->findDeclarations(QualifiedIdentifier(u"foo< T >")).size(), 1);
527 QCOMPARE(file.topContext()->findDeclarations(QualifiedIdentifier(u"foo< T >::bar")).size(), 1);
528
529 auto mainCtx = file.topContext()->localDeclarations().last()->internalContext()->childContexts().first();
530 QVERIFY(mainCtx);
531 auto myFoo = mainCtx->localDeclarations().first();
532 QVERIFY(myFoo);
533 QCOMPARE(myFoo->abstractType()->toString().remove(' '), QStringLiteral("foo<int>"));
534}
535
536void TestDUChain::testNamespace()
537{

Callers

nothing calls this directly

Calls 13

parseAndWaitMethod · 0.80
localDeclarationsMethod · 0.80
findDeclarationsMethod · 0.80
childContextsMethod · 0.80
QualifiedIdentifierClass · 0.50
topContextMethod · 0.45
sizeMethod · 0.45
firstMethod · 0.45
internalContextMethod · 0.45
lastMethod · 0.45
removeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected