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

Method testMacroDefinition

plugins/clang/tests/test_duchain.cpp:220–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220void TestDUChain::testMacroDefinition()
221{
222 QFETCH(QString, code);
223 QFETCH(QString, definition);
224 QFETCH(bool, isFunctionLike);
225 QFETCH(QVector<QString>, parameters);
226
227 TestFile file(code, QStringLiteral("cpp"));
228 QVERIFY(file.parseAndWait());
229
230 DUChainReadLocker lock;
231 auto top = file.topContext();
232 QVERIFY(top);
233 QCOMPARE(top->localDeclarations().size(), 1);
234
235 const auto decl = top->localDeclarations().constFirst();
236 QVERIFY(decl);
237
238 const auto macro = dynamic_cast<const MacroDefinition*>(decl);
239 QVERIFY(macro);
240
241 QCOMPARE(macro->definition().str(), definition);
242
243 QCOMPARE(macro->isFunctionLike(), isFunctionLike);
244
245 // The displayed tooltip for these incorrectly parsed macros looks good, but the bogus
246 // single macro parameter in the MacroDefinition object could cause issues in the future.
247 QEXPECT_FAIL("only_escaped_newline_in_parens(\\\n)", "difficult to parse, uncommon, not yet a problem", Continue);
248 QEXPECT_FAIL("only_comment_in_parens(/*comment*/)", "difficult to parse, uncommon, not yet a problem", Continue);
249 QCOMPARE(macro->parametersSize(), parameters.size());
250
251 const IndexedString* actualParam = macro->parameters();
252 for (const auto& expectedParam : parameters) {
253 QCOMPARE(actualParam->str(), expectedParam);
254 ++actualParam;
255 }
256}
257
258void TestDUChain::testMacroDefinition_data()
259{

Callers

nothing calls this directly

Calls 9

parseAndWaitMethod · 0.80
localDeclarationsMethod · 0.80
strMethod · 0.80
isFunctionLikeMethod · 0.80
parametersSizeMethod · 0.80
topContextMethod · 0.45
sizeMethod · 0.45
definitionMethod · 0.45
parametersMethod · 0.45

Tested by

no test coverage detected