diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2014-02-23 23:53:22 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2014-03-04 14:37:56 +0100 |
commit | 151899b1b8a046d9c3c31d229519a2f430f1e514 (patch) | |
tree | ca58fa22776c335749dd024624cc5ab68f6b20a4 /src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp | |
parent | 29091078ad5d0ad3c7688fef227ab72dcef1fac1 (diff) |
CppTools: Avoid matching function by name only
Compare full function signature, or at least argument count.
Task-number: QTCREATORBUG-10295
Change-Id: Iead4d067209a8aea77cfcea2cd1ca5d08f87b165
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp')
-rw-r--r-- | src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 714344f0795..d3947b478c9 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -332,6 +332,7 @@ F2TestCase::F2TestCase(CppEditorAction action, // qDebug() << "Expected column:" << expectedColumn; QEXPECT_FAIL("globalVarFromEnum", "Contributor works on a fix.", Abort); + QEXPECT_FAIL("matchFunctionSignature_Follow_5", "foo(int) resolved as CallAST", Abort); QCOMPARE(currentTextEditor->currentLine(), expectedLine); QCOMPARE(currentTextEditor->currentColumn() - 1, expectedColumn); @@ -452,6 +453,50 @@ void CppEditorPlugin::test_SwitchMethodDeclarationDefinition_data() " return 1 + 1;\n" "}\n" // Line 10 ); + + QTest::newRow("matchFunctionSignature_Def_1") << _( + "class Foo {\n" + " void @foo(int);\n" + " void foo();\n" + "};\n" + ) << _( + "#include \"file.h\"\n" + "void Foo::$foo(int) {}\n" + ); + + QTest::newRow("matchFunctionSignature_Def_2") << _( + "class Foo {\n" + " void $foo(int);\n" + " void foo();\n" + "};\n" + ) << _( + "#include \"file.h\"\n" + "void Foo::@foo(int) {}\n" + ); + + QTest::newRow("matchFunctionSignature_Def_3") << _( + "class Foo {\n" + " void foo(int);\n" + " void @$foo() {}\n" + "};\n" + ) << _( + "#include \"file.h\"\n" + "void Foo::foo(int) {}\n" + ); + + QTest::newRow("matchFunctionSignature_Def_4") << _( + "class Foo {\n" + " void foo(int);\n" + " void @$foo();\n" + "};\n" + ) << _(); + + QTest::newRow("matchFunctionSignature_Def_5") << _( + "class Foo {\n" + " void @$foo(int);\n" + " void foo();\n" + "};\n" + ) << _(); } void CppEditorPlugin::test_SwitchMethodDeclarationDefinition() @@ -818,6 +863,44 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data() " @Foo foo;\n" "}\n" ); + + QTest::newRow("matchFunctionSignature_Follow_1") << _( + "class Foo {\n" + " void @foo(int);\n" + " void foo();\n" + "};\n" + "void Foo::$foo(int) {}\n" + ); + + QTest::newRow("matchFunctionSignature_Follow_2") << _( + "class Foo {\n" + " void $foo(int);\n" + " void foo();\n" + "};\n" + "void Foo::@foo(int) {}\n" + ); + + QTest::newRow("matchFunctionSignature_Follow_3") << _( + "class Foo {\n" + " void foo(int);\n" + " void @$foo() {}\n" + "};\n" + "void Foo::foo(int) {}\n" + ); + + QTest::newRow("matchFunctionSignature_Follow_4") << _( + "class Foo {\n" + " void foo(int);\n" + " void @$foo();\n" + "};\n" + ); + + QTest::newRow("matchFunctionSignature_Follow_5") << _( + "class Foo {\n" + " void @$foo(int);\n" + " void foo();\n" + "};\n" + ); } void CppEditorPlugin::test_FollowSymbolUnderCursor() @@ -845,6 +928,17 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data() "@Container<int> container;\n", "forwardDeclaredAndUsed.h") ); + + QTest::newRow("matchFunctionSignature") << (QList<TestDocumentPtr>() + << TestDocument::create("class Foo {\n" + " void @foo(int);\n" + " void foo() {}\n" + "};\n", + "foo.h") + << TestDocument::create("#include \"foo.h\"\n" + "void Foo::$foo(int) {}\n", + "foo.cpp") + ); } void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments() |