diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2014-06-25 18:17:58 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2014-07-04 16:39:29 +0200 |
commit | a22d281cc60532a8044add5a5abd7b5a59545b68 (patch) | |
tree | 41dec851c67b13158b4e2d63eb9f65c192fdcc64 | |
parent | 52ef14190e949c91a4a5023831be1d5771ef72a5 (diff) |
CppEditor: Add failing tests for "Move Definition Outside Class"...
... when macros are used in function definition
Task-number: QTCREATORBUG-12314
Change-Id: I811f93cde3dffa75fb71684569706f284939d7f5
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
-rw-r--r-- | src/plugins/cppeditor/cppeditorplugin.h | 2 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfix_test.cpp | 69 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfix_test.h | 3 |
3 files changed, 72 insertions, 2 deletions
diff --git a/src/plugins/cppeditor/cppeditorplugin.h b/src/plugins/cppeditor/cppeditorplugin.h index c6c2d77d3d..ec1f6aa8eb 100644 --- a/src/plugins/cppeditor/cppeditorplugin.h +++ b/src/plugins/cppeditor/cppeditorplugin.h @@ -182,6 +182,7 @@ private slots: void test_quickfix_MoveFuncDefOutside_afterClass(); void test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1(); void test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2(); + void test_quickfix_MoveFuncDefOutside_macroUses(); void test_quickfix_MoveFuncDefToDecl_MemberFunc(); void test_quickfix_MoveFuncDefToDecl_MemberFuncOutside(); @@ -192,6 +193,7 @@ private slots: void test_quickfix_MoveFuncDefToDecl_FreeFuncToCppNS(); void test_quickfix_MoveFuncDefToDecl_CtorWithInitialization(); void test_quickfix_MoveFuncDefToDecl_structWithAssignedVariable(); + void test_quickfix_MoveFuncDefToDecl_macroUses(); void test_quickfix_AssignToLocalVariable_templates(); diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index 745362f4fe..ce9853714b 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -124,7 +124,8 @@ static QString &removeTrailingWhitespace(QString &input) QuickFixTestCase::QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTestFiles, CppQuickFixFactory *factory, const ProjectPart::HeaderPaths &headerPaths, - int resultIndex) + int resultIndex, + const QByteArray &expectedFailMessage) : m_testFiles(theTestFiles) , m_cppCodeStylePreferences(0) , m_restoreHeaderPaths(false) @@ -196,6 +197,8 @@ QuickFixTestCase::QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTe // Check QString result = testFile->m_editorWidget->document()->toPlainText(); removeTrailingWhitespace(result); + if (!expectedFailMessage.isEmpty()) + QEXPECT_FAIL("", expectedFailMessage.data(), Continue); QCOMPARE(result, testFile->m_expectedSource); // Undo the change @@ -3007,6 +3010,39 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2 QuickFixTestCase(singleDocument(original, expected), &factory); } +void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_macroUses() +{ + QByteArray original = + "#define CONST const\n" + "#define VOLATILE volatile\n" + "class Foo\n" + "{\n" + " int fu@nc(int a, int b) CONST VOLATILE\n" + " {\n" + " return 42;\n" + " }\n" + "};\n"; + QByteArray expected = + "#define CONST const\n" + "#define VOLATILE volatile\n" + "class Foo\n" + "{\n" + " int func(int a, int b) CONST VOLATILE;\n" + "};\n" + "\n" + "\n" + // const volatile become lowercase: QTCREATORBUG-12620 + "int Foo::func(int a, int b) const volatile\n" + "{\n" + " return 42;\n" + "}\n" + ; + + MoveFuncDefOutside factory; + QuickFixTestCase(singleDocument(original, expected), &factory, + ProjectPart::HeaderPaths(), 0, "QTCREATORBUG-12314"); +} + /// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp() void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc() { @@ -3310,6 +3346,37 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_structWithAssignedVariable QuickFixTestCase(singleDocument(original, expected), &factory); } +void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_macroUses() +{ + QByteArray original = + "#define CONST const\n" + "#define VOLATILE volatile\n" + "class Foo\n" + "{\n" + " int func(int a, int b) CONST VOLATILE;\n" + "};\n" + "\n" + "\n" + "int Foo::fu@nc(int a, int b) CONST VOLATILE" + "{\n" + " return 42;\n" + "}\n"; + QByteArray expected = + "#define CONST const\n" + "#define VOLATILE volatile\n" + "class Foo\n" + "{\n" + " int func(int a, int b) CONST VOLATILE\n" + " {\n" + " return 42;\n" + " }\n" + "};\n\n\n\n"; + + MoveFuncDefToDecl factory; + QuickFixTestCase(singleDocument(original, expected), &factory, + ProjectPart::HeaderPaths(), 0, "QTCREATORBUG-12314"); +} + void CppEditorPlugin::test_quickfix_AssignToLocalVariable_templates() { diff --git a/src/plugins/cppeditor/cppquickfix_test.h b/src/plugins/cppeditor/cppquickfix_test.h index f15335cf0b..a898c8bb36 100644 --- a/src/plugins/cppeditor/cppquickfix_test.h +++ b/src/plugins/cppeditor/cppquickfix_test.h @@ -76,7 +76,8 @@ public: CppQuickFixFactory *factory, const CppTools::ProjectPart::HeaderPaths &includePaths = CppTools::ProjectPart::HeaderPaths(), - int resultIndex = 0); + int resultIndex = 0, + const QByteArray &expectedFailMessage = QByteArray()); ~QuickFixTestCase(); static void run(const QList<QuickFixTestDocument::Ptr> &theTestFiles, |