diff options
author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2009-11-11 09:35:42 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@nokia.com> | 2009-11-11 09:35:42 +0100 |
commit | 2d2d0b59c81628516c84f1573250c5fb79f1803c (patch) | |
tree | f8121294d6612ca1fddf27079b928e8f01947f1c /tests | |
parent | a6bbec2b56f4a07f408bf3213b3b15fa6fc10330 (diff) | |
download | qt-creator-2d2d0b59c81628516c84f1573250c5fb79f1803c.tar.gz |
Changed ExpressionUnderCursor to handle Objective-C send-message operations.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/cplusplus/semantic/tst_semantic.cpp | 139 |
1 files changed, 138 insertions, 1 deletions
diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index 31b5f208b4..33ddf1c3e5 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -78,7 +78,7 @@ public: : errorCount(0) { } - virtual void report(int level, + virtual void report(int /*level*/, StringLiteral *fileName, unsigned line, unsigned column, const char *format, va_list ap) @@ -118,6 +118,15 @@ private slots: void expression_under_cursor_1(); + void bracketed_expression_under_cursor_1(); + void bracketed_expression_under_cursor_2(); + void bracketed_expression_under_cursor_3(); + void bracketed_expression_under_cursor_4(); + void bracketed_expression_under_cursor_5(); + void bracketed_expression_under_cursor_6(); + void bracketed_expression_under_cursor_7(); + void bracketed_expression_under_cursor_8(); + void objcClass_1(); }; @@ -447,6 +456,134 @@ void tst_Semantic::expression_under_cursor_1() QCOMPARE(expression, QString("bar")); } +void tst_Semantic::bracketed_expression_under_cursor_1() +{ + const QString plainText = "int i = 0, j[1], k = j[i"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, QString("i")); +} + +void tst_Semantic::bracketed_expression_under_cursor_2() +{ + const QString plainText = "[receiver msg"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, plainText); +} + +void tst_Semantic::bracketed_expression_under_cursor_3() +{ + const QString plainText = "[receiver msgParam1:0 msgParam2"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, plainText); +} + +void tst_Semantic::bracketed_expression_under_cursor_4() +{ + const QString plainText = "[receiver msgParam1:0 msgParam2:@\"zoo\" msgParam3"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, plainText); +} + +void tst_Semantic::bracketed_expression_under_cursor_5() +{ + const QString plainText = "if ([receiver message"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, QString("[receiver message")); +} + +void tst_Semantic::bracketed_expression_under_cursor_6() +{ + const QString plainText = "if ([receiver msgParam1:1 + i[1] msgParam2"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, QString("[receiver msgParam1:1 + i[1] msgParam2")); +} + +void tst_Semantic::bracketed_expression_under_cursor_7() +{ + const QString plainText = "int i = 0, j[1], k = j[(i == 0) ? 0 : i"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, QString("i")); +} + +void tst_Semantic::bracketed_expression_under_cursor_8() +{ + const QString plainText = "[[receiver msg] param1:[receiver msg] param2"; + + QTextDocument textDocument; + textDocument.setPlainText(plainText); + + QTextCursor tc(&textDocument); + tc.movePosition(QTextCursor::End); + + ExpressionUnderCursor expressionUnderCursor; + const QString expression = expressionUnderCursor(tc); + + QCOMPARE(expression, plainText); +} + void tst_Semantic::objcClass_1() { QSharedPointer<Document> doc = document("\n" |