From 5fe3ead73ef730fa1659bd17af206ec94a428159 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 27 Aug 2021 13:15:46 +0200 Subject: CppTools/CppEditor: Rename the TestDocument classes It was not helpful that we had four different classes with the same name. Note that they look suspiciously similar and could possibly be merged into a single class at some point. Change-Id: I7d4c10a09408226037bc0d276940bca39dc5f576 Reviewed-by: Christian Stenger --- .../followsymbol_switchmethoddecldef_test.cpp | 66 +++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp') diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 1472c11bf1c..fd25211090d 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -192,8 +192,8 @@ private: CppEditorWidget *m_editorWidget; }; -class TestDocument; -typedef QSharedPointer TestDocumentPtr; +class FollowSymbolTestDocument; +typedef QSharedPointer TestDocumentPtr; /** * Represents a test document. @@ -202,11 +202,11 @@ typedef QSharedPointer TestDocumentPtr; * - a '@' character denotes the initial text cursor position * - a '$' character denotes the target text cursor position */ -class TestDocument : public Tests::TestDocument +class FollowSymbolTestDocument : public Tests::GenericCppTestDocument { public: - TestDocument(const QByteArray &source, const QByteArray &fileName) - : Tests::TestDocument(fileName, source) + FollowSymbolTestDocument(const QByteArray &source, const QByteArray &fileName) + : Tests::GenericCppTestDocument(fileName, source) , m_targetCursorPosition(m_source.indexOf(QLatin1Char('$'))) { if (m_cursorPosition != -1 || m_targetCursorPosition != -1) @@ -229,7 +229,7 @@ public: static TestDocumentPtr create(const QByteArray &source, const QByteArray &fileName) { - return TestDocumentPtr(new TestDocument(source, fileName)); + return TestDocumentPtr(new FollowSymbolTestDocument(source, fileName)); } bool hasTargetCursorMarker() const { return m_targetCursorPosition != -1; } @@ -240,7 +240,7 @@ public: QList singleDocument(const QByteArray &source) { - return QList() << TestDocument::create(source, "file.cpp"); + return QList() << FollowSymbolTestDocument::create(source, "file.cpp"); } /** @@ -340,7 +340,7 @@ F2TestCase::F2TestCase(CppEditorAction action, } projectCloser; if (useClangd) { - TestDocument projectFile(projectFileContent.toUtf8(), "project.qbs"); + FollowSymbolTestDocument projectFile(projectFileContent.toUtf8(), "project.qbs"); projectFile.setBaseDirectory(temporaryDir.path()); QVERIFY(projectFile.writeToDisk()); const auto openProjectResult = @@ -870,8 +870,8 @@ void FollowSymbolTest::testSwitchMethodDeclDef() QFETCH(QByteArray, source); const QList testFiles = QList() - << TestDocument::create(header, "file.h") - << TestDocument::create(source, "file.cpp"); + << FollowSymbolTestDocument::create(header, "file.h") + << FollowSymbolTestDocument::create(source, "file.cpp"); F2TestCase(F2TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles); } @@ -1444,87 +1444,87 @@ void FollowSymbolTest::testFollowSymbolMultipleDocuments_data() QTest::addColumn >("documents"); QTest::newRow("skipForwardDeclarationBasic") << (QList() - << TestDocument::create("class $Foo {};\n", + << FollowSymbolTestDocument::create("class $Foo {};\n", "defined.h") - << TestDocument::create("class Foo;\n" + << FollowSymbolTestDocument::create("class Foo;\n" "@Foo foo;\n", "forwardDeclaredAndUsed.h") ); QTest::newRow("skipForwardDeclarationTemplates") << (QList() - << TestDocument::create("template class $Container {};\n", + << FollowSymbolTestDocument::create("template class $Container {};\n", "defined.h") - << TestDocument::create("template class Container;\n" + << FollowSymbolTestDocument::create("template class Container;\n" "@Container container;\n", "forwardDeclaredAndUsed.h") ); QTest::newRow("matchFunctionSignature") << (QList() - << TestDocument::create("class Foo {\n" + << FollowSymbolTestDocument::create("class Foo {\n" " void @foo(int);\n" " void foo() {}\n" "};\n", "foo.h") - << TestDocument::create("#include \"foo.h\"\n" + << FollowSymbolTestDocument::create("#include \"foo.h\"\n" "void Foo::$foo(int) {}\n", "foo.cpp") ); QTest::newRow("matchFunctionSignature2") << (QList() - << TestDocument::create("namespace N { class C; }\n" + << FollowSymbolTestDocument::create("namespace N { class C; }\n" "bool *@fun(N::C *) const;\n", "foo.h") - << TestDocument::create("#include \"foo.h\"\n" + << FollowSymbolTestDocument::create("#include \"foo.h\"\n" "using namespace N;\n" "bool *$fun(C *) const {}\n", "foo.cpp") ); QTest::newRow("matchFunctionSignatureFuzzy1Forward") << (QList() - << TestDocument::create("class Foo {\n" + << FollowSymbolTestDocument::create("class Foo {\n" " void @foo(int);\n" " void foo();\n" "};\n", "foo.h") - << TestDocument::create("#include \"foo.h\"\n" + << FollowSymbolTestDocument::create("#include \"foo.h\"\n" "void Foo::$foo() {}\n", "foo.cpp") ); QTest::newRow("matchFunctionSignatureFuzzy1Backward") << (QList() - << TestDocument::create("class Foo {\n" + << FollowSymbolTestDocument::create("class Foo {\n" " void $foo(int);\n" "};\n", "foo.h") - << TestDocument::create("#include \"foo.h\"\n" + << FollowSymbolTestDocument::create("#include \"foo.h\"\n" "void Foo::@foo() {}\n", "foo.cpp") ); QTest::newRow("matchFunctionSignatureFuzzy2Forward") << (QList() - << TestDocument::create("class Foo {\n" + << FollowSymbolTestDocument::create("class Foo {\n" " void foo(int);\n" " void @foo();\n" "};\n", "foo.h") - << TestDocument::create("#include \"foo.h\"\n" + << FollowSymbolTestDocument::create("#include \"foo.h\"\n" "void Foo::$foo(int) {}\n", "foo.cpp") ); QTest::newRow("matchFunctionSignatureFuzzy2Backward") << (QList() - << TestDocument::create("class Foo {\n" + << FollowSymbolTestDocument::create("class Foo {\n" " void $foo();\n" "};\n", "foo.h") - << TestDocument::create("#include \"foo.h\"\n" + << FollowSymbolTestDocument::create("#include \"foo.h\"\n" "void Foo::@foo(int) {}\n", "foo.cpp") ); QTest::newRow("globalVar") << QList{ - TestDocument::create("namespace NS { extern int @globalVar; }\n", "file.h"), - TestDocument::create( + FollowSymbolTestDocument::create("namespace NS { extern int @globalVar; }\n", "file.h"), + FollowSymbolTestDocument::create( "int globalVar;\n" "namespace NS {\n" "extern int globalVar;\n" @@ -1532,7 +1532,7 @@ void FollowSymbolTest::testFollowSymbolMultipleDocuments_data() "}\n", "file.cpp")}; QTest::newRow("staticMemberVar") << QList{ - TestDocument::create( + FollowSymbolTestDocument::create( "namespace NS {\n" "class Test {\n" " static int @var;\n" @@ -1540,7 +1540,7 @@ void FollowSymbolTest::testFollowSymbolMultipleDocuments_data() "class OtherClass { static int var; };\n" "}\n" "class OtherClass { static int var; };\n", "file.h"), - TestDocument::create( + FollowSymbolTestDocument::create( "#include \"file.h\"\n" "int var;\n" "int OtherClass::var;\n" @@ -2063,12 +2063,12 @@ void FollowSymbolTest::testFollowVirtualFunctionCall() void FollowSymbolTest::testFollowVirtualFunctionCallMultipleDocuments() { QList testFiles = QList() - << TestDocument::create("struct A { virtual void virt(int) = 0; };\n", + << FollowSymbolTestDocument::create("struct A { virtual void virt(int) = 0; };\n", "a.h") - << TestDocument::create("#include \"a.h\"\n" + << FollowSymbolTestDocument::create("#include \"a.h\"\n" "struct B : A { void virt(int) {} };\n", "b.h") - << TestDocument::create("#include \"a.h\"\n" + << FollowSymbolTestDocument::create("#include \"a.h\"\n" "void f(A *o) { o->$@virt(42); }\n", "u.cpp") ; -- cgit v1.2.3