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

Method testOverloadedFunctions

plugins/clang/tests/test_codecompletion.cpp:1217–1244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1215}
1216
1217void TestCodeCompletion::testOverloadedFunctions()
1218{
1219 TestFile file(QStringLiteral("void f(); int f(int); void f(int, double){\n "), QStringLiteral("cpp"));
1220 QVERIFY(file.parseAndWait(TopDUContext::AllDeclarationsContextsUsesAndAST));
1221 DUChainReadLocker lock;
1222 auto top = file.topContext();
1223 QVERIFY(top);
1224 const ParseSessionData::Ptr sessionData(dynamic_cast<ParseSessionData*>(top->ast().data()));
1225 QVERIFY(sessionData);
1226
1227 lock.unlock();
1228
1229 const auto context = createContext(top, sessionData, {1, 0});
1230 context->setFilters(NoMacroOrBuiltin);
1231 lock.lock();
1232 const auto tester = ClangCodeCompletionItemTester(context);
1233 QCOMPARE(tester.items.size(), 3);
1234 for (const auto& item : tester.items) {
1235 auto function = item->declaration()->type<FunctionType>();
1236 const QString display = item->declaration()->identifier().toString() + function->partToString(FunctionType::SignatureArguments);
1237 const QString itemDisplay = tester.itemData(item).toString() + tester.itemData(item, KTextEditor:: CodeCompletionModel::Arguments).toString();
1238 QCOMPARE(display, itemDisplay);
1239 }
1240
1241 QVERIFY(tester.items[0]->declaration().data() != tester.items[1]->declaration().data());
1242 QVERIFY(tester.items[0]->declaration().data() != tester.items[2]->declaration().data());
1243 QVERIFY(tester.items[1]->declaration().data() != tester.items[2]->declaration().data());
1244}
1245
1246void TestCodeCompletion::testCompletionPriority()
1247{

Callers

nothing calls this directly

Calls 14

createContextFunction · 0.85
parseAndWaitMethod · 0.80
partToStringMethod · 0.80
topContextMethod · 0.45
dataMethod · 0.45
astMethod · 0.45
unlockMethod · 0.45
setFiltersMethod · 0.45
lockMethod · 0.45
sizeMethod · 0.45
declarationMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected