diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index 4e1586e68b52ee5aa8b96906387d70eda4abeeb3..827a227f053db188aa0c4f2505f4d9ba2a7f193f 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -1,6 +1,8 @@ #include <QtTest> #include <QtDebug> +#include <QTextDocument> +#include <QTextCursor> #include <Control.h> #include <Parser.h> @@ -14,6 +16,7 @@ #include <DiagnosticClient.h> #include <GenTemplateInstance.h> #include <Overview.h> +#include <ExpressionUnderCursor.h> using namespace CPlusPlus; @@ -105,6 +108,8 @@ private slots: void pointer_to_function_1(); void template_instance_1(); + + void expression_under_cursor_1(); }; void tst_Semantic::function_declaration_1() @@ -417,5 +422,21 @@ void tst_Semantic::template_instance_1() QCOMPARE(genDecl, QString::fromLatin1("void(const int &)")); } +void tst_Semantic::expression_under_cursor_1() +{ + const QString plainText = "void *ptr = foo(10, bar"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, QString("bar")); +} + QTEST_APPLESS_MAIN(tst_Semantic) #include "tst_semantic.moc"