本文整理汇总了C++中document::Ptr::functionAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::functionAt方法的具体用法?C++ Ptr::functionAt怎么用?C++ Ptr::functionAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document::Ptr
的用法示例。
在下文中一共展示了Ptr::functionAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: for
void tst_Lookup::document_functionAt_1()
{
const QByteArray source = "\n"
"void Foo::Bar() {\n" // line 1
" \n" // line 2
" for (int i=0; i < 10; ++i) {\n"
" \n" // line 4
" }\n"
"}\n"; // line 7
Document::Ptr doc = Document::create("document_functionAt_1");
doc->setUtf8Source(source);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->functionAt(1, 2), QString());
QCOMPARE(doc->functionAt(1, 11), QString(QLatin1String("Foo::Bar")));
QCOMPARE(doc->functionAt(2, 2), QString(QLatin1String("Foo::Bar")));
QCOMPARE(doc->functionAt(3, 10), QString(QLatin1String("Foo::Bar")));
QCOMPARE(doc->functionAt(4, 3), QString(QLatin1String("Foo::Bar")));
QCOMPARE(doc->functionAt(6, 1), QString(QLatin1String("Foo::Bar")));
}
示例2: document_functionAt
void tst_Lookup::document_functionAt()
{
QFETCH(QByteArray, source);
QFETCH(int, line);
QFETCH(int, column);
QFETCH(QString, expectedFunction);
QFETCH(int, expectedOpeningDeclaratorParenthesisLine);
QFETCH(int, expectedClosingBraceLine);
Document::Ptr doc = Document::create("document_functionAt");
doc->setUtf8Source(source);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
int actualOpeningDeclaratorParenthesisLine = -1;
int actualClosingBraceLine = -1;
const QString actualFunction = doc->functionAt(line, column,
&actualOpeningDeclaratorParenthesisLine,
&actualClosingBraceLine);
QCOMPARE(actualFunction, expectedFunction);
QCOMPARE(actualOpeningDeclaratorParenthesisLine, expectedOpeningDeclaratorParenthesisLine);
QCOMPARE(actualClosingBraceLine, expectedClosingBraceLine);
}