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

Method testGetCursorSignature

plugins/clang/tests/test_clangutils.cpp:265–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265void TestClangUtils::testGetCursorSignature()
266{
267 QFETCH(QByteArray, code);
268 QFETCH(QString, expectedSignature);
269
270 QString fileName;
271 auto unit = parse(code, &fileName);
272 CXCursor functionCursor = clang_getNullCursor();
273 const auto startCursor = clang_getTranslationUnitCursor(unit.get());
274 ClangUtils::visitChildren(startCursor, [&](CXCursor cursor, CXCursor){
275 switch (clang_getCursorKind(cursor))
276 {
277 case CXCursor_FunctionDecl:
278 case CXCursor_CXXMethod:
279 case CXCursor_FunctionTemplate:
280 functionCursor = cursor;
281 return CXChildVisit_Break;
282 default:
283 return CXChildVisit_Recurse;
284 }
285 });
286 QVERIFY2(!clang_Cursor_isNull(functionCursor), "function not found");
287 auto scope = ClangUtils::getScope(functionCursor, startCursor);
288 auto signature = ClangUtils::getCursorSignature(functionCursor, scope, {});
289 QCOMPARE(signature, expectedSignature);
290}
291
292void TestClangUtils::testGetCursorSignature_data()
293{

Callers

nothing calls this directly

Calls 2

parseFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected