forked from qt-creator/qt-creator
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 <christian.stenger@qt.io>
This commit is contained in:
@@ -375,7 +375,7 @@ void DoxygenTest::testWithMacroFromHeaderBeforeFunction()
|
|||||||
" */\n"
|
" */\n"
|
||||||
"API void f();\n";
|
"API void f();\n";
|
||||||
|
|
||||||
const TestDocument headerDocumentDefiningMacro("header.h", "#define API\n");
|
const GenericCppTestDocument headerDocumentDefiningMacro("header.h", "#define API\n");
|
||||||
|
|
||||||
runTest(given, expected, /*settings=*/ 0, {headerDocumentDefiningMacro});
|
runTest(given, expected, /*settings=*/ 0, {headerDocumentDefiningMacro});
|
||||||
}
|
}
|
||||||
@@ -421,12 +421,12 @@ void DoxygenTest::runTest(const QByteArray &original,
|
|||||||
// Write files to disk
|
// Write files to disk
|
||||||
CppTools::Tests::TemporaryDir temporaryDir;
|
CppTools::Tests::TemporaryDir temporaryDir;
|
||||||
QVERIFY(temporaryDir.isValid());
|
QVERIFY(temporaryDir.isValid());
|
||||||
TestDocument testDocument("file.cpp", original, '|');
|
GenericCppTestDocument testDocument("file.cpp", original, '|');
|
||||||
QVERIFY(testDocument.hasCursorMarker());
|
QVERIFY(testDocument.hasCursorMarker());
|
||||||
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
|
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
|
||||||
testDocument.setBaseDirectory(temporaryDir.path());
|
testDocument.setBaseDirectory(temporaryDir.path());
|
||||||
QVERIFY(testDocument.writeToDisk());
|
QVERIFY(testDocument.writeToDisk());
|
||||||
foreach (TestDocument testDocument, includedHeaderDocuments) {
|
foreach (GenericCppTestDocument testDocument, includedHeaderDocuments) {
|
||||||
testDocument.setBaseDirectory(temporaryDir.path());
|
testDocument.setBaseDirectory(temporaryDir.path());
|
||||||
QVERIFY(testDocument.writeToDisk());
|
QVERIFY(testDocument.writeToDisk());
|
||||||
}
|
}
|
||||||
|
@@ -47,8 +47,9 @@ namespace CppEditor {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
namespace Tests {
|
namespace Tests {
|
||||||
|
|
||||||
TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker)
|
GenericCppTestDocument::GenericCppTestDocument(const QByteArray &fileName, const QByteArray &source,
|
||||||
: CppTools::Tests::TestDocument(fileName, source, cursorMarker)
|
char cursorMarker)
|
||||||
|
: CppTools::Tests::BaseCppTestDocument(fileName, source, cursorMarker)
|
||||||
, m_cursorPosition(-1)
|
, m_cursorPosition(-1)
|
||||||
, m_anchorPosition(-1)
|
, m_anchorPosition(-1)
|
||||||
, m_selectionStartMarker(QLatin1Char(m_cursorMarker) + QLatin1String("{start}"))
|
, m_selectionStartMarker(QLatin1Char(m_cursorMarker) + QLatin1String("{start}"))
|
||||||
@@ -73,9 +74,9 @@ TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestDocument::hasCursorMarker() const { return m_cursorPosition != -1; }
|
bool GenericCppTestDocument::hasCursorMarker() const { return m_cursorPosition != -1; }
|
||||||
|
|
||||||
bool TestDocument::hasAnchorMarker() const { return m_anchorPosition != -1; }
|
bool GenericCppTestDocument::hasAnchorMarker() const { return m_anchorPosition != -1; }
|
||||||
|
|
||||||
TestCase::TestCase(bool runGarbageCollector)
|
TestCase::TestCase(bool runGarbageCollector)
|
||||||
: CppTools::Tests::TestCase(runGarbageCollector)
|
: CppTools::Tests::TestCase(runGarbageCollector)
|
||||||
|
@@ -37,10 +37,11 @@ class CppEditorWidget;
|
|||||||
|
|
||||||
namespace Tests {
|
namespace Tests {
|
||||||
|
|
||||||
class TestDocument : public CppTools::Tests::TestDocument
|
class GenericCppTestDocument : public CppTools::Tests::BaseCppTestDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker = '@');
|
GenericCppTestDocument(const QByteArray &fileName, const QByteArray &source,
|
||||||
|
char cursorMarker = '@');
|
||||||
|
|
||||||
bool hasCursorMarker() const;
|
bool hasCursorMarker() const;
|
||||||
bool hasAnchorMarker() const;
|
bool hasAnchorMarker() const;
|
||||||
@@ -54,7 +55,7 @@ public:
|
|||||||
CppEditorWidget *m_editorWidget;
|
CppEditorWidget *m_editorWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
using TestDocuments = QVector<TestDocument>;
|
using TestDocuments = QVector<GenericCppTestDocument>;
|
||||||
|
|
||||||
class TestCase : public CppTools::Tests::TestCase
|
class TestCase : public CppTools::Tests::TestCase
|
||||||
{
|
{
|
||||||
|
@@ -86,7 +86,7 @@ QuickFixTestDocument::Ptr QuickFixTestDocument::create(const QByteArray &fileNam
|
|||||||
QuickFixTestDocument::QuickFixTestDocument(const QByteArray &fileName,
|
QuickFixTestDocument::QuickFixTestDocument(const QByteArray &fileName,
|
||||||
const QByteArray &source,
|
const QByteArray &source,
|
||||||
const QByteArray &expectedSource)
|
const QByteArray &expectedSource)
|
||||||
: TestDocument(fileName, source)
|
: GenericCppTestDocument(fileName, source)
|
||||||
, m_expectedSource(QString::fromUtf8(expectedSource))
|
, m_expectedSource(QString::fromUtf8(expectedSource))
|
||||||
{
|
{
|
||||||
removeMarkers();
|
removeMarkers();
|
||||||
|
@@ -50,7 +50,7 @@ namespace Tests {
|
|||||||
/// reads the document.
|
/// reads the document.
|
||||||
///
|
///
|
||||||
|
|
||||||
class QuickFixTestDocument : public TestDocument
|
class QuickFixTestDocument : public GenericCppTestDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QSharedPointer<QuickFixTestDocument> Ptr;
|
typedef QSharedPointer<QuickFixTestDocument> Ptr;
|
||||||
|
@@ -70,7 +70,7 @@ namespace Tests {
|
|||||||
class UseSelectionsTestCase : public TestCase
|
class UseSelectionsTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UseSelectionsTestCase(TestDocument &testDocument,
|
UseSelectionsTestCase(GenericCppTestDocument &testDocument,
|
||||||
const SelectionList &expectedSelections);
|
const SelectionList &expectedSelections);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -82,7 +82,7 @@ private:
|
|||||||
CppEditorWidget *m_editorWidget = nullptr;
|
CppEditorWidget *m_editorWidget = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
UseSelectionsTestCase::UseSelectionsTestCase(TestDocument &testFile,
|
UseSelectionsTestCase::UseSelectionsTestCase(GenericCppTestDocument &testFile,
|
||||||
const SelectionList &expectedSelections)
|
const SelectionList &expectedSelections)
|
||||||
{
|
{
|
||||||
QVERIFY(succeededSoFar());
|
QVERIFY(succeededSoFar());
|
||||||
@@ -253,7 +253,7 @@ void SelectionsTest::testUseSelections()
|
|||||||
QFETCH(QByteArray, source);
|
QFETCH(QByteArray, source);
|
||||||
QFETCH(SelectionList, expectedSelections);
|
QFETCH(SelectionList, expectedSelections);
|
||||||
|
|
||||||
Tests::TestDocument testDocument("file.cpp", source);
|
Tests::GenericCppTestDocument testDocument("file.cpp", source);
|
||||||
Tests::UseSelectionsTestCase(testDocument, expectedSelections);
|
Tests::UseSelectionsTestCase(testDocument, expectedSelections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -192,8 +192,8 @@ private:
|
|||||||
CppEditorWidget *m_editorWidget;
|
CppEditorWidget *m_editorWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestDocument;
|
class FollowSymbolTestDocument;
|
||||||
typedef QSharedPointer<TestDocument> TestDocumentPtr;
|
typedef QSharedPointer<FollowSymbolTestDocument> TestDocumentPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a test document.
|
* Represents a test document.
|
||||||
@@ -202,11 +202,11 @@ typedef QSharedPointer<TestDocument> TestDocumentPtr;
|
|||||||
* - a '@' character denotes the initial text cursor position
|
* - a '@' character denotes the initial text cursor position
|
||||||
* - a '$' character denotes the target text cursor position
|
* - a '$' character denotes the target text cursor position
|
||||||
*/
|
*/
|
||||||
class TestDocument : public Tests::TestDocument
|
class FollowSymbolTestDocument : public Tests::GenericCppTestDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestDocument(const QByteArray &source, const QByteArray &fileName)
|
FollowSymbolTestDocument(const QByteArray &source, const QByteArray &fileName)
|
||||||
: Tests::TestDocument(fileName, source)
|
: Tests::GenericCppTestDocument(fileName, source)
|
||||||
, m_targetCursorPosition(m_source.indexOf(QLatin1Char('$')))
|
, m_targetCursorPosition(m_source.indexOf(QLatin1Char('$')))
|
||||||
{
|
{
|
||||||
if (m_cursorPosition != -1 || m_targetCursorPosition != -1)
|
if (m_cursorPosition != -1 || m_targetCursorPosition != -1)
|
||||||
@@ -229,7 +229,7 @@ public:
|
|||||||
|
|
||||||
static TestDocumentPtr create(const QByteArray &source, const QByteArray &fileName)
|
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; }
|
bool hasTargetCursorMarker() const { return m_targetCursorPosition != -1; }
|
||||||
@@ -240,7 +240,7 @@ public:
|
|||||||
|
|
||||||
QList<TestDocumentPtr> singleDocument(const QByteArray &source)
|
QList<TestDocumentPtr> singleDocument(const QByteArray &source)
|
||||||
{
|
{
|
||||||
return QList<TestDocumentPtr>() << TestDocument::create(source, "file.cpp");
|
return QList<TestDocumentPtr>() << FollowSymbolTestDocument::create(source, "file.cpp");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,7 +340,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
|||||||
} projectCloser;
|
} projectCloser;
|
||||||
|
|
||||||
if (useClangd) {
|
if (useClangd) {
|
||||||
TestDocument projectFile(projectFileContent.toUtf8(), "project.qbs");
|
FollowSymbolTestDocument projectFile(projectFileContent.toUtf8(), "project.qbs");
|
||||||
projectFile.setBaseDirectory(temporaryDir.path());
|
projectFile.setBaseDirectory(temporaryDir.path());
|
||||||
QVERIFY(projectFile.writeToDisk());
|
QVERIFY(projectFile.writeToDisk());
|
||||||
const auto openProjectResult =
|
const auto openProjectResult =
|
||||||
@@ -870,8 +870,8 @@ void FollowSymbolTest::testSwitchMethodDeclDef()
|
|||||||
QFETCH(QByteArray, source);
|
QFETCH(QByteArray, source);
|
||||||
|
|
||||||
const QList<TestDocumentPtr> testFiles = QList<TestDocumentPtr>()
|
const QList<TestDocumentPtr> testFiles = QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create(header, "file.h")
|
<< FollowSymbolTestDocument::create(header, "file.h")
|
||||||
<< TestDocument::create(source, "file.cpp");
|
<< FollowSymbolTestDocument::create(source, "file.cpp");
|
||||||
|
|
||||||
F2TestCase(F2TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
|
F2TestCase(F2TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
|
||||||
}
|
}
|
||||||
@@ -1444,87 +1444,87 @@ void FollowSymbolTest::testFollowSymbolMultipleDocuments_data()
|
|||||||
QTest::addColumn<QList<TestDocumentPtr> >("documents");
|
QTest::addColumn<QList<TestDocumentPtr> >("documents");
|
||||||
|
|
||||||
QTest::newRow("skipForwardDeclarationBasic") << (QList<TestDocumentPtr>()
|
QTest::newRow("skipForwardDeclarationBasic") << (QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("class $Foo {};\n",
|
<< FollowSymbolTestDocument::create("class $Foo {};\n",
|
||||||
"defined.h")
|
"defined.h")
|
||||||
<< TestDocument::create("class Foo;\n"
|
<< FollowSymbolTestDocument::create("class Foo;\n"
|
||||||
"@Foo foo;\n",
|
"@Foo foo;\n",
|
||||||
"forwardDeclaredAndUsed.h")
|
"forwardDeclaredAndUsed.h")
|
||||||
);
|
);
|
||||||
|
|
||||||
QTest::newRow("skipForwardDeclarationTemplates") << (QList<TestDocumentPtr>()
|
QTest::newRow("skipForwardDeclarationTemplates") << (QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("template <class E> class $Container {};\n",
|
<< FollowSymbolTestDocument::create("template <class E> class $Container {};\n",
|
||||||
"defined.h")
|
"defined.h")
|
||||||
<< TestDocument::create("template <class E> class Container;\n"
|
<< FollowSymbolTestDocument::create("template <class E> class Container;\n"
|
||||||
"@Container<int> container;\n",
|
"@Container<int> container;\n",
|
||||||
"forwardDeclaredAndUsed.h")
|
"forwardDeclaredAndUsed.h")
|
||||||
);
|
);
|
||||||
|
|
||||||
QTest::newRow("matchFunctionSignature") << (QList<TestDocumentPtr>()
|
QTest::newRow("matchFunctionSignature") << (QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("class Foo {\n"
|
<< FollowSymbolTestDocument::create("class Foo {\n"
|
||||||
" void @foo(int);\n"
|
" void @foo(int);\n"
|
||||||
" void foo() {}\n"
|
" void foo() {}\n"
|
||||||
"};\n",
|
"};\n",
|
||||||
"foo.h")
|
"foo.h")
|
||||||
<< TestDocument::create("#include \"foo.h\"\n"
|
<< FollowSymbolTestDocument::create("#include \"foo.h\"\n"
|
||||||
"void Foo::$foo(int) {}\n",
|
"void Foo::$foo(int) {}\n",
|
||||||
"foo.cpp")
|
"foo.cpp")
|
||||||
);
|
);
|
||||||
|
|
||||||
QTest::newRow("matchFunctionSignature2") << (QList<TestDocumentPtr>()
|
QTest::newRow("matchFunctionSignature2") << (QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("namespace N { class C; }\n"
|
<< FollowSymbolTestDocument::create("namespace N { class C; }\n"
|
||||||
"bool *@fun(N::C *) const;\n",
|
"bool *@fun(N::C *) const;\n",
|
||||||
"foo.h")
|
"foo.h")
|
||||||
<< TestDocument::create("#include \"foo.h\"\n"
|
<< FollowSymbolTestDocument::create("#include \"foo.h\"\n"
|
||||||
"using namespace N;\n"
|
"using namespace N;\n"
|
||||||
"bool *$fun(C *) const {}\n",
|
"bool *$fun(C *) const {}\n",
|
||||||
"foo.cpp")
|
"foo.cpp")
|
||||||
);
|
);
|
||||||
|
|
||||||
QTest::newRow("matchFunctionSignatureFuzzy1Forward") << (QList<TestDocumentPtr>()
|
QTest::newRow("matchFunctionSignatureFuzzy1Forward") << (QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("class Foo {\n"
|
<< FollowSymbolTestDocument::create("class Foo {\n"
|
||||||
" void @foo(int);\n"
|
" void @foo(int);\n"
|
||||||
" void foo();\n"
|
" void foo();\n"
|
||||||
"};\n",
|
"};\n",
|
||||||
"foo.h")
|
"foo.h")
|
||||||
<< TestDocument::create("#include \"foo.h\"\n"
|
<< FollowSymbolTestDocument::create("#include \"foo.h\"\n"
|
||||||
"void Foo::$foo() {}\n",
|
"void Foo::$foo() {}\n",
|
||||||
"foo.cpp")
|
"foo.cpp")
|
||||||
);
|
);
|
||||||
|
|
||||||
QTest::newRow("matchFunctionSignatureFuzzy1Backward") << (QList<TestDocumentPtr>()
|
QTest::newRow("matchFunctionSignatureFuzzy1Backward") << (QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("class Foo {\n"
|
<< FollowSymbolTestDocument::create("class Foo {\n"
|
||||||
" void $foo(int);\n"
|
" void $foo(int);\n"
|
||||||
"};\n",
|
"};\n",
|
||||||
"foo.h")
|
"foo.h")
|
||||||
<< TestDocument::create("#include \"foo.h\"\n"
|
<< FollowSymbolTestDocument::create("#include \"foo.h\"\n"
|
||||||
"void Foo::@foo() {}\n",
|
"void Foo::@foo() {}\n",
|
||||||
"foo.cpp")
|
"foo.cpp")
|
||||||
);
|
);
|
||||||
|
|
||||||
QTest::newRow("matchFunctionSignatureFuzzy2Forward") << (QList<TestDocumentPtr>()
|
QTest::newRow("matchFunctionSignatureFuzzy2Forward") << (QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("class Foo {\n"
|
<< FollowSymbolTestDocument::create("class Foo {\n"
|
||||||
" void foo(int);\n"
|
" void foo(int);\n"
|
||||||
" void @foo();\n"
|
" void @foo();\n"
|
||||||
"};\n",
|
"};\n",
|
||||||
"foo.h")
|
"foo.h")
|
||||||
<< TestDocument::create("#include \"foo.h\"\n"
|
<< FollowSymbolTestDocument::create("#include \"foo.h\"\n"
|
||||||
"void Foo::$foo(int) {}\n",
|
"void Foo::$foo(int) {}\n",
|
||||||
"foo.cpp")
|
"foo.cpp")
|
||||||
);
|
);
|
||||||
|
|
||||||
QTest::newRow("matchFunctionSignatureFuzzy2Backward") << (QList<TestDocumentPtr>()
|
QTest::newRow("matchFunctionSignatureFuzzy2Backward") << (QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("class Foo {\n"
|
<< FollowSymbolTestDocument::create("class Foo {\n"
|
||||||
" void $foo();\n"
|
" void $foo();\n"
|
||||||
"};\n",
|
"};\n",
|
||||||
"foo.h")
|
"foo.h")
|
||||||
<< TestDocument::create("#include \"foo.h\"\n"
|
<< FollowSymbolTestDocument::create("#include \"foo.h\"\n"
|
||||||
"void Foo::@foo(int) {}\n",
|
"void Foo::@foo(int) {}\n",
|
||||||
"foo.cpp")
|
"foo.cpp")
|
||||||
);
|
);
|
||||||
|
|
||||||
QTest::newRow("globalVar") << QList<TestDocumentPtr>{
|
QTest::newRow("globalVar") << QList<TestDocumentPtr>{
|
||||||
TestDocument::create("namespace NS { extern int @globalVar; }\n", "file.h"),
|
FollowSymbolTestDocument::create("namespace NS { extern int @globalVar; }\n", "file.h"),
|
||||||
TestDocument::create(
|
FollowSymbolTestDocument::create(
|
||||||
"int globalVar;\n"
|
"int globalVar;\n"
|
||||||
"namespace NS {\n"
|
"namespace NS {\n"
|
||||||
"extern int globalVar;\n"
|
"extern int globalVar;\n"
|
||||||
@@ -1532,7 +1532,7 @@ void FollowSymbolTest::testFollowSymbolMultipleDocuments_data()
|
|||||||
"}\n", "file.cpp")};
|
"}\n", "file.cpp")};
|
||||||
|
|
||||||
QTest::newRow("staticMemberVar") << QList<TestDocumentPtr>{
|
QTest::newRow("staticMemberVar") << QList<TestDocumentPtr>{
|
||||||
TestDocument::create(
|
FollowSymbolTestDocument::create(
|
||||||
"namespace NS {\n"
|
"namespace NS {\n"
|
||||||
"class Test {\n"
|
"class Test {\n"
|
||||||
" static int @var;\n"
|
" static int @var;\n"
|
||||||
@@ -1540,7 +1540,7 @@ void FollowSymbolTest::testFollowSymbolMultipleDocuments_data()
|
|||||||
"class OtherClass { static int var; };\n"
|
"class OtherClass { static int var; };\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"class OtherClass { static int var; };\n", "file.h"),
|
"class OtherClass { static int var; };\n", "file.h"),
|
||||||
TestDocument::create(
|
FollowSymbolTestDocument::create(
|
||||||
"#include \"file.h\"\n"
|
"#include \"file.h\"\n"
|
||||||
"int var;\n"
|
"int var;\n"
|
||||||
"int OtherClass::var;\n"
|
"int OtherClass::var;\n"
|
||||||
@@ -2063,12 +2063,12 @@ void FollowSymbolTest::testFollowVirtualFunctionCall()
|
|||||||
void FollowSymbolTest::testFollowVirtualFunctionCallMultipleDocuments()
|
void FollowSymbolTest::testFollowVirtualFunctionCallMultipleDocuments()
|
||||||
{
|
{
|
||||||
QList<TestDocumentPtr> testFiles = QList<TestDocumentPtr>()
|
QList<TestDocumentPtr> testFiles = QList<TestDocumentPtr>()
|
||||||
<< TestDocument::create("struct A { virtual void virt(int) = 0; };\n",
|
<< FollowSymbolTestDocument::create("struct A { virtual void virt(int) = 0; };\n",
|
||||||
"a.h")
|
"a.h")
|
||||||
<< TestDocument::create("#include \"a.h\"\n"
|
<< FollowSymbolTestDocument::create("#include \"a.h\"\n"
|
||||||
"struct B : A { void virt(int) {} };\n",
|
"struct B : A { void virt(int) {} };\n",
|
||||||
"b.h")
|
"b.h")
|
||||||
<< TestDocument::create("#include \"a.h\"\n"
|
<< FollowSymbolTestDocument::create("#include \"a.h\"\n"
|
||||||
"void f(A *o) { o->$@virt(42); }\n",
|
"void f(A *o) { o->$@virt(42); }\n",
|
||||||
"u.cpp")
|
"u.cpp")
|
||||||
;
|
;
|
||||||
|
@@ -74,13 +74,13 @@ static bool snapshotContains(const CPlusPlus::Snapshot &snapshot, const QSet<QSt
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker)
|
BaseCppTestDocument::BaseCppTestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker)
|
||||||
: m_fileName(QString::fromUtf8(fileName))
|
: m_fileName(QString::fromUtf8(fileName))
|
||||||
, m_source(QString::fromUtf8(source))
|
, m_source(QString::fromUtf8(source))
|
||||||
, m_cursorMarker(cursorMarker)
|
, m_cursorMarker(cursorMarker)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QString TestDocument::filePath() const
|
QString BaseCppTestDocument::filePath() const
|
||||||
{
|
{
|
||||||
if (!m_baseDirectory.isEmpty())
|
if (!m_baseDirectory.isEmpty())
|
||||||
return QDir::cleanPath(m_baseDirectory + QLatin1Char('/') + m_fileName);
|
return QDir::cleanPath(m_baseDirectory + QLatin1Char('/') + m_fileName);
|
||||||
@@ -91,7 +91,7 @@ QString TestDocument::filePath() const
|
|||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestDocument::writeToDisk() const
|
bool BaseCppTestDocument::writeToDisk() const
|
||||||
{
|
{
|
||||||
return TestCase::writeFile(filePath(), m_source.toUtf8());
|
return TestCase::writeFile(filePath(), m_source.toUtf8());
|
||||||
}
|
}
|
||||||
|
@@ -74,10 +74,11 @@ template <typename Signal> inline bool waitForSignalOrTimeout(
|
|||||||
return timer.isActive();
|
return timer.isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
class CPPTOOLS_EXPORT TestDocument
|
class CPPTOOLS_EXPORT BaseCppTestDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker = '@');
|
BaseCppTestDocument(const QByteArray &fileName, const QByteArray &source,
|
||||||
|
char cursorMarker = '@');
|
||||||
|
|
||||||
QString baseDirectory() const { return m_baseDirectory; }
|
QString baseDirectory() const { return m_baseDirectory; }
|
||||||
void setBaseDirectory(const QString &baseDirectory) { m_baseDirectory = baseDirectory; }
|
void setBaseDirectory(const QString &baseDirectory) { m_baseDirectory = baseDirectory; }
|
||||||
|
@@ -40,9 +40,9 @@
|
|||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
using namespace CppTools::Internal;
|
using namespace CppTools::Internal;
|
||||||
using Tests::TestDocument;
|
using Tests::BaseCppTestDocument;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QList<TestDocument>)
|
Q_DECLARE_METATYPE(QList<BaseCppTestDocument>)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ private:
|
|||||||
class TypeHierarchyBuilderTestCase : public Tests::TestCase
|
class TypeHierarchyBuilderTestCase : public Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TypeHierarchyBuilderTestCase(const QList<TestDocument> &documents,
|
TypeHierarchyBuilderTestCase(const QList<BaseCppTestDocument> &documents,
|
||||||
const QString &expectedHierarchy)
|
const QString &expectedHierarchy)
|
||||||
{
|
{
|
||||||
QVERIFY(succeededSoFar());
|
QVERIFY(succeededSoFar());
|
||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
Tests::TemporaryDir temporaryDir;
|
Tests::TemporaryDir temporaryDir;
|
||||||
QVERIFY(temporaryDir.isValid());
|
QVERIFY(temporaryDir.isValid());
|
||||||
|
|
||||||
QList<TestDocument> documents_ = documents;
|
QList<BaseCppTestDocument> documents_ = documents;
|
||||||
|
|
||||||
// Write files
|
// Write files
|
||||||
QSet<QString> filePaths;
|
QSet<QString> filePaths;
|
||||||
@@ -138,12 +138,12 @@ public:
|
|||||||
|
|
||||||
void TypeHierarchyBuilderTest::test_data()
|
void TypeHierarchyBuilderTest::test_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QList<TestDocument> >("documents");
|
QTest::addColumn<QList<BaseCppTestDocument> >("documents");
|
||||||
QTest::addColumn<QString>("expectedHierarchy");
|
QTest::addColumn<QString>("expectedHierarchy");
|
||||||
|
|
||||||
QTest::newRow("basic-single-document")
|
QTest::newRow("basic-single-document")
|
||||||
<< (QList<TestDocument>()
|
<< (QList<BaseCppTestDocument>()
|
||||||
<< TestDocument("a.h",
|
<< BaseCppTestDocument("a.h",
|
||||||
"class A {};\n"
|
"class A {};\n"
|
||||||
"class B : public A {};\n"
|
"class B : public A {};\n"
|
||||||
"class C1 : public B {};\n"
|
"class C1 : public B {};\n"
|
||||||
@@ -157,19 +157,19 @@ void TypeHierarchyBuilderTest::test_data()
|
|||||||
" C2\n" );
|
" C2\n" );
|
||||||
|
|
||||||
QTest::newRow("basic-multiple-documents")
|
QTest::newRow("basic-multiple-documents")
|
||||||
<< (QList<TestDocument>()
|
<< (QList<BaseCppTestDocument>()
|
||||||
<< TestDocument("a.h",
|
<< BaseCppTestDocument("a.h",
|
||||||
"class A {};")
|
"class A {};")
|
||||||
<< TestDocument("b.h",
|
<< BaseCppTestDocument("b.h",
|
||||||
"#include \"a.h\"\n"
|
"#include \"a.h\"\n"
|
||||||
"class B : public A {};")
|
"class B : public A {};")
|
||||||
<< TestDocument("c1.h",
|
<< BaseCppTestDocument("c1.h",
|
||||||
"#include \"b.h\"\n"
|
"#include \"b.h\"\n"
|
||||||
"class C1 : public B {};")
|
"class C1 : public B {};")
|
||||||
<< TestDocument("c2.h",
|
<< BaseCppTestDocument("c2.h",
|
||||||
"#include \"b.h\"\n"
|
"#include \"b.h\"\n"
|
||||||
"class C2 : public B {};")
|
"class C2 : public B {};")
|
||||||
<< TestDocument("d.h",
|
<< BaseCppTestDocument("d.h",
|
||||||
"#include \"c1.h\"\n"
|
"#include \"c1.h\"\n"
|
||||||
"class D : public C1 {};"))
|
"class D : public C1 {};"))
|
||||||
<< QString::fromLatin1(
|
<< QString::fromLatin1(
|
||||||
@@ -183,7 +183,7 @@ void TypeHierarchyBuilderTest::test_data()
|
|||||||
|
|
||||||
void TypeHierarchyBuilderTest::test()
|
void TypeHierarchyBuilderTest::test()
|
||||||
{
|
{
|
||||||
QFETCH(QList<TestDocument>, documents);
|
QFETCH(QList<BaseCppTestDocument>, documents);
|
||||||
QFETCH(QString, expectedHierarchy);
|
QFETCH(QString, expectedHierarchy);
|
||||||
|
|
||||||
TypeHierarchyBuilderTestCase(documents, expectedHierarchy);
|
TypeHierarchyBuilderTestCase(documents, expectedHierarchy);
|
||||||
|
Reference in New Issue
Block a user