| 511 | } |
| 512 | |
| 513 | void 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 | |
| 536 | void TestDUChain::testNamespace() |
| 537 | { |
nothing calls this directly
no test coverage detected