Commit 0bd59178 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppEditor/CppTools: Don't continue in test function on failure

QVERIFY/QCOMPARE are meant to be called in the test function so that on
failure they just can "return" and thus skip subsequent code. Since we
use reusable test code in the test functions (the *TestCase classes), we
need to ensure that on failure no further test code is executed.

This mostly inlines the run function of the test classes into the
constructor.

Change-Id: I320ee032bdde0174ddfe3fdf3f9e18e19abf1d7f
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent c7f3ac40
...@@ -62,56 +62,49 @@ typedef QByteArray _; ...@@ -62,56 +62,49 @@ typedef QByteArray _;
class DoxygenTestCase : public CppEditor::Internal::Tests::TestCase class DoxygenTestCase : public CppEditor::Internal::Tests::TestCase
{ {
public: public:
DoxygenTestCase(const QByteArray &input); /// The '|' in the input denotes the cursor position.
void run(const QByteArray &expected); DoxygenTestCase(const QByteArray &original, const QByteArray &expected)
{
private: QVERIFY(succeededSoFar());
CppEditor::Internal::Tests::TestDocument testDocument;
CppEditor::Internal::Tests::TestDocument testDocument("file.cpp", original, '|');
QVERIFY(testDocument.hasCursorMarker());
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
QVERIFY(testDocument.writeToDisk());
// Update Code Model
QVERIFY(parseFiles(testDocument.filePath()));
// Open Editor
QVERIFY(openCppEditor(testDocument.filePath(), &testDocument.m_editor,
&testDocument.m_editorWidget));
closeEditorAtEndOfTestCase(testDocument.m_editor);
// We want to test documents that start with a comment. By default, the
// editor will fold the very first comment it encounters, assuming
// it is a license header. Currently unfoldAll() does not work as
// expected (some blocks are still hidden in some test cases, so the
// cursor movements are not as expected). For the time being, we just
// prepend a declaration before the initial test comment.
// testDocument.m_editorWidget->unfoldAll();
testDocument.m_editor->setCursorPosition(testDocument.m_cursorPosition);
waitForRehighlightedSemanticDocument(testDocument.m_editorWidget);
// Send 'ENTER' key press
QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
QCoreApplication::sendEvent(testDocument.m_editorWidget, &event);
const QByteArray result = testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(QLatin1String(result), QLatin1String(expected));
testDocument.m_editorWidget->undo();
const QByteArray contentsAfterUndo
= testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(contentsAfterUndo, testDocument.m_source);
}
}; };
/// The '|' in the input denotes the cursor position.
DoxygenTestCase::DoxygenTestCase(const QByteArray &input)
: testDocument("file.cpp", input, '|')
{
QVERIFY(testDocument.hasCursorMarker());
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
QVERIFY(testDocument.writeToDisk());
// Update Code Model
QVERIFY(parseFiles(testDocument.filePath()));
// Open Editor
QVERIFY(openCppEditor(testDocument.filePath(), &testDocument.m_editor,
&testDocument.m_editorWidget));
closeEditorAtEndOfTestCase(testDocument.m_editor);
// We want to test documents that start with a comment. By default, the
// editor will fold the very first comment it encounters, assuming
// it is a license header. Currently unfoldAll() does not work as
// expected (some blocks are still hidden in some test cases, so the
// cursor movements are not as expected). For the time being, we just
// prepend a declaration before the initial test comment.
// testDocument.m_editorWidget->unfoldAll();
testDocument.m_editor->setCursorPosition(testDocument.m_cursorPosition);
waitForRehighlightedSemanticDocument(testDocument.m_editorWidget);
}
void DoxygenTestCase::run(const QByteArray &expected)
{
// Send 'ENTER' key press
QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
QCoreApplication::sendEvent(testDocument.m_editorWidget, &event);
const QByteArray result = testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(QLatin1String(result), QLatin1String(expected));
testDocument.m_editorWidget->undo();
const QByteArray contentsAfterUndo
= testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(contentsAfterUndo, testDocument.m_source);
}
} // anonymous namespace } // anonymous namespace
void CppEditorPlugin::test_doxygen_comments_data() void CppEditorPlugin::test_doxygen_comments_data()
...@@ -257,6 +250,5 @@ void CppEditorPlugin::test_doxygen_comments() ...@@ -257,6 +250,5 @@ void CppEditorPlugin::test_doxygen_comments()
{ {
QFETCH(QByteArray, given); QFETCH(QByteArray, given);
QFETCH(QByteArray, expected); QFETCH(QByteArray, expected);
DoxygenTestCase test(given); DoxygenTestCase(given, expected);
test.run(expected);
} }
...@@ -49,8 +49,12 @@ namespace { ...@@ -49,8 +49,12 @@ namespace {
class IncludeHierarchyTestCase: public CppEditor::Internal::Tests::TestCase class IncludeHierarchyTestCase: public CppEditor::Internal::Tests::TestCase
{ {
public: public:
IncludeHierarchyTestCase(const QList<QByteArray> &sourceList) IncludeHierarchyTestCase(const QList<QByteArray> &sourceList,
int includesCount,
int includedByCount)
{ {
QVERIFY(succeededSoFar());
QStringList filePaths; QStringList filePaths;
const int sourceListSize = sourceList.size(); const int sourceListSize = sourceList.size();
for (int i = 0; i < sourceListSize; ++i) { for (int i = 0; i < sourceListSize; ++i) {
...@@ -66,16 +70,14 @@ public: ...@@ -66,16 +70,14 @@ public:
// Update Code Model // Update Code Model
QVERIFY(parseFiles(filePaths)); QVERIFY(parseFiles(filePaths));
}
void run(int includesCount, int includedByCount) // Open Editor
{
const QString fileName = QDir::tempPath() + QLatin1String("/file1.h"); const QString fileName = QDir::tempPath() + QLatin1String("/file1.h");
CPPEditor *editor; CPPEditor *editor;
QVERIFY(openCppEditor(fileName, &editor)); QVERIFY(openCppEditor(fileName, &editor));
closeEditorAtEndOfTestCase(editor); closeEditorAtEndOfTestCase(editor);
// Test model
CppIncludeHierarchyModel model(0); CppIncludeHierarchyModel model(0);
model.buildHierarchy(editor, fileName); model.buildHierarchy(editor, fileName);
QCOMPARE(model.rowCount(model.index(0, 0)), includesCount); QCOMPARE(model.rowCount(model.index(0, 0)), includesCount);
...@@ -91,8 +93,7 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludes() ...@@ -91,8 +93,7 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludes()
sourceList.append(QByteArray("#include \"file2.h\"\n")); sourceList.append(QByteArray("#include \"file2.h\"\n"));
sourceList.append(QByteArray()); sourceList.append(QByteArray());
IncludeHierarchyTestCase testCase(sourceList); IncludeHierarchyTestCase(sourceList, 1, 0);
testCase.run(1, 0);
} }
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy() void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy()
...@@ -101,8 +102,7 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy() ...@@ -101,8 +102,7 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy()
sourceList.append(QByteArray()); sourceList.append(QByteArray());
sourceList.append(QByteArray("#include \"file1.h\"\n")); sourceList.append(QByteArray("#include \"file1.h\"\n"));
IncludeHierarchyTestCase testCase(sourceList); IncludeHierarchyTestCase(sourceList, 0, 1);
testCase.run(0, 1);
} }
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy() void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy()
...@@ -112,6 +112,5 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy() ...@@ -112,6 +112,5 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy()
sourceList.append(QByteArray()); sourceList.append(QByteArray());
sourceList.append(QByteArray("#include \"file1.h\"\n")); sourceList.append(QByteArray("#include \"file1.h\"\n"));
IncludeHierarchyTestCase testCase(sourceList); IncludeHierarchyTestCase(sourceList, 1, 1);
testCase.run(1, 1);
} }
...@@ -97,6 +97,11 @@ public: ...@@ -97,6 +97,11 @@ public:
QByteArray m_expectedSource; QByteArray m_expectedSource;
}; };
QList<TestDocumentPtr> singleDocument(const QByteArray &original, const QByteArray &expected)
{
return QList<TestDocumentPtr>() << TestDocument::create("file.cpp", original, expected);
}
/** /**
* Encapsulates the whole process of setting up an editor, getting the * Encapsulates the whole process of setting up an editor, getting the
* quick-fix, applying it, and checking the result. * quick-fix, applying it, and checking the result.
...@@ -104,19 +109,15 @@ public: ...@@ -104,19 +109,15 @@ public:
class QuickFixTestCase : public CppEditor::Internal::Tests::TestCase class QuickFixTestCase : public CppEditor::Internal::Tests::TestCase
{ {
public: public:
QuickFixTestCase(const QByteArray &originalSource, const QByteArray &expectedSource,
const QStringList &includePaths = QStringList());
QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles, QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles,
const QStringList &includePaths = QStringList()); CppQuickFixFactory *factory,
const QStringList &includePaths = QStringList(),
int resultIndex = 0);
~QuickFixTestCase(); ~QuickFixTestCase();
void run(CppQuickFixFactory *factory, int resultIndex = 0);
private: private:
TestDocumentPtr testFileWithCursorMarker() const;
QuickFixOperation::Ptr getFix(CppQuickFixFactory *factory, CPPEditorWidget *editorWidget, QuickFixOperation::Ptr getFix(CppQuickFixFactory *factory, CPPEditorWidget *editorWidget,
int resultIndex = 0); int resultIndex = 0);
void init(const QStringList &includePaths);
private: private:
QList<TestDocumentPtr> m_testFiles; QList<TestDocumentPtr> m_testFiles;
...@@ -139,29 +140,38 @@ QuickFixOperation::Ptr QuickFixTestCase::getFix(CppQuickFixFactory *factory, ...@@ -139,29 +140,38 @@ QuickFixOperation::Ptr QuickFixTestCase::getFix(CppQuickFixFactory *factory,
return results.isEmpty() ? QuickFixOperation::Ptr() : results.at(resultIndex); return results.isEmpty() ? QuickFixOperation::Ptr() : results.at(resultIndex);
} }
/// The '@' in the originalSource is the position from where the quick-fix discovery is triggered. /// Leading whitespace is not removed, so we can check if the indetation ranges
QuickFixTestCase::QuickFixTestCase(const QByteArray &originalSource, /// have been set correctly by the quick-fix.
const QByteArray &expectedSource, QByteArray &removeTrailingWhitespace(QByteArray &input)
const QStringList &includePaths)
: m_cppCodeStylePreferences(0)
, m_restoreIncludePaths(false)
{ {
m_testFiles << TestDocument::create("file.cpp", originalSource, expectedSource); QList<QByteArray> lines = input.split('\n');
init(includePaths); input.resize(0);
foreach (QByteArray line, lines) {
while (line.length() > 0) {
char lastChar = line[line.length() - 1];
if (lastChar == ' ' || lastChar == '\t')
line = line.left(line.length() - 1);
else
break;
}
input.append(line);
input.append('\n');
}
return input;
} }
/// The '@' in the originalSource is the position from where the quick-fix discovery is triggered.
/// Exactly one TestFile must contain the cursor position marker '@' in the originalSource. /// Exactly one TestFile must contain the cursor position marker '@' in the originalSource.
QuickFixTestCase::QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles, QuickFixTestCase::QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles,
const QStringList &includePaths) CppQuickFixFactory *factory,
const QStringList &includePaths,
int resultIndex)
: m_testFiles(theTestFiles) : m_testFiles(theTestFiles)
, m_cppCodeStylePreferences(0) , m_cppCodeStylePreferences(0)
, m_restoreIncludePaths(false) , m_restoreIncludePaths(false)
{ {
init(includePaths); QVERIFY(succeededSoFar());
}
void QuickFixTestCase::init(const QStringList &includePaths)
{
// Check if there is exactly one cursor marker // Check if there is exactly one cursor marker
unsigned cursorMarkersCount = 0; unsigned cursorMarkersCount = 0;
foreach (const TestDocumentPtr testFile, m_testFiles) { foreach (const TestDocumentPtr testFile, m_testFiles) {
...@@ -208,45 +218,7 @@ void QuickFixTestCase::init(const QStringList &includePaths) ...@@ -208,45 +218,7 @@ void QuickFixTestCase::init(const QStringList &includePaths)
QVERIFY(m_cppCodeStylePreferences); QVERIFY(m_cppCodeStylePreferences);
m_cppCodeStylePreferencesOriginalDelegateId = m_cppCodeStylePreferences->currentDelegateId(); m_cppCodeStylePreferencesOriginalDelegateId = m_cppCodeStylePreferences->currentDelegateId();
m_cppCodeStylePreferences->setCurrentDelegate("qt"); m_cppCodeStylePreferences->setCurrentDelegate("qt");
}
QuickFixTestCase::~QuickFixTestCase()
{
// Restore default cpp code style
if (m_cppCodeStylePreferences)
m_cppCodeStylePreferences->setCurrentDelegate(m_cppCodeStylePreferencesOriginalDelegateId);
// Restore include paths
if (m_restoreIncludePaths)
m_modelManager->setIncludePaths(m_includePathsToRestore);
// Remove created files from file system
foreach (const TestDocumentPtr &testDocument, m_testFiles)
QVERIFY(QFile::remove(testDocument->filePath()));
}
/// Leading whitespace is not removed, so we can check if the indetation ranges
/// have been set correctly by the quick-fix.
QByteArray &removeTrailingWhitespace(QByteArray &input)
{
QList<QByteArray> lines = input.split('\n');
input.resize(0);
foreach (QByteArray line, lines) {
while (line.length() > 0) {
char lastChar = line[line.length() - 1];
if (lastChar == ' ' || lastChar == '\t')
line = line.left(line.length() - 1);
else
break;
}
input.append(line);
input.append('\n');
}
return input;
}
void QuickFixTestCase::run(CppQuickFixFactory *factory, int resultIndex)
{
// Run the fix in the file having the cursor marker // Run the fix in the file having the cursor marker
TestDocumentPtr testFile; TestDocumentPtr testFile;
foreach (const TestDocumentPtr file, m_testFiles) { foreach (const TestDocumentPtr file, m_testFiles) {
...@@ -275,6 +247,21 @@ void QuickFixTestCase::run(CppQuickFixFactory *factory, int resultIndex) ...@@ -275,6 +247,21 @@ void QuickFixTestCase::run(CppQuickFixFactory *factory, int resultIndex)
} }
} }
QuickFixTestCase::~QuickFixTestCase()
{
// Restore default cpp code style
if (m_cppCodeStylePreferences)
m_cppCodeStylePreferences->setCurrentDelegate(m_cppCodeStylePreferencesOriginalDelegateId);
// Restore include paths
if (m_restoreIncludePaths)
m_modelManager->setIncludePaths(m_includePathsToRestore);
// Remove created files from file system
foreach (const TestDocumentPtr &testDocument, m_testFiles)
QVERIFY(QFile::remove(testDocument->filePath()));
}
/// Delegates directly to AddIncludeForUndefinedIdentifierOp for easier testing. /// Delegates directly to AddIncludeForUndefinedIdentifierOp for easier testing.
class AddIncludeForUndefinedIdentifierTestFactory : public CppQuickFixFactory class AddIncludeForUndefinedIdentifierTestFactory : public CppQuickFixFactory
{ {
...@@ -1200,8 +1187,7 @@ void CppEditorPlugin::test_quickfix() ...@@ -1200,8 +1187,7 @@ void CppEditorPlugin::test_quickfix()
if (expected.isEmpty()) if (expected.isEmpty())
expected = original + '\n'; expected = original + '\n';
QuickFixTestCase test(original, expected); QuickFixTestCase(singleDocument(original, expected), factory.data());
test.run(factory.data());
} }
/// Checks: In addition to test_quickfix_GenerateGetterSetter_basicGetterWithPrefix /// Checks: In addition to test_quickfix_GenerateGetterSetter_basicGetterWithPrefix
...@@ -1254,8 +1240,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAn ...@@ -1254,8 +1240,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAn
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory; GenerateGetterSetter factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check if definition is inserted right after class for insert definition outside /// Check if definition is inserted right after class for insert definition outside
...@@ -1298,8 +1283,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass() ...@@ -1298,8 +1283,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory, QStringList(), 1);
test.run(&factory, 1);
} }
/// Check from header file: If there is a source file, insert the definition in the source file. /// Check from header file: If there is a source file, insert the definition in the source file.
...@@ -1332,8 +1316,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1() ...@@ -1332,8 +1316,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check from header file: If there is a source file, insert the definition in the source file. /// Check from header file: If there is a source file, insert the definition in the source file.
...@@ -1371,8 +1354,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2() ...@@ -1371,8 +1354,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check from source file: Insert in source file, not header file. /// Check from source file: Insert in source file, not header file.
...@@ -1403,8 +1385,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic3() ...@@ -1403,8 +1385,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic3()
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check from header file: If the class is in a namespace, the added function definition /// Check from header file: If the class is in a namespace, the added function definition
...@@ -1439,8 +1420,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace1() ...@@ -1439,8 +1420,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace1()
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check from header file: If the class is in namespace N and the source file has a /// Check from header file: If the class is in namespace N and the source file has a
...@@ -1479,8 +1459,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2() ...@@ -1479,8 +1459,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2()
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check definition insert inside class /// Check definition insert inside class
...@@ -1498,8 +1477,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass() ...@@ -1498,8 +1477,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
"};\n"; "};\n";
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(original, expected); QuickFixTestCase(singleDocument(original, expected), &factory, QStringList(), 1);
test.run(&factory, 1);
} }
/// Check not triggering when definition exists /// Check not triggering when definition exists
...@@ -1513,8 +1491,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio ...@@ -1513,8 +1491,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
const QByteArray expected = original + "\n"; const QByteArray expected = original + "\n";
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(original, expected); QuickFixTestCase test(singleDocument(original, expected), &factory, QStringList(), 1);
test.run(&factory, 1);
} }
/// Find right implementation file. /// Find right implementation file.
...@@ -1565,8 +1542,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil ...@@ -1565,8 +1542,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
testFiles << TestDocument::create("file2.cpp", original, expected); testFiles << TestDocument::create("file2.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Ignore generated functions declarations when looking at the surrounding /// Ignore generated functions declarations when looking at the surrounding
...@@ -1622,8 +1598,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_ignoreSurroundingGenerated ...@@ -1622,8 +1598,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_ignoreSurroundingGenerated
testFiles << TestDocument::create("file2.cpp", original, expected); testFiles << TestDocument::create("file2.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check if whitespace is respected for operator functions /// Check if whitespace is respected for operator functions
...@@ -1648,8 +1623,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1( ...@@ -1648,8 +1623,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1(
"\n"; "\n";
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(original, expected); QuickFixTestCase(singleDocument(original, expected), &factory);
test.run(&factory);
} }
/// Check if whitespace is respected for operator functions /// Check if whitespace is respected for operator functions
...@@ -1674,8 +1648,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2( ...@@ -1674,8 +1648,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2(
"\n"; "\n";
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(original, expected); QuickFixTestCase(singleDocument(original, expected), &factory);
test.run(&factory);
} }
/// Check if a function like macro use is not separated by the function to insert /// Check if a function like macro use is not separated by the function to insert
...@@ -1718,8 +1691,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1() ...@@ -1718,8 +1691,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1()
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check if a function like macro use is not separated by the function to insert /// Check if a function like macro use is not separated by the function to insert
...@@ -1760,8 +1732,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2() ...@@ -1760,8 +1732,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2()
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);
} }
/// Check if insertion happens before syntactically erroneous statements at end of file. /// Check if insertion happens before syntactically erroneous statements at end of file.
...@@ -1799,8 +1770,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfF ...@@ -1799,8 +1770,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfF
testFiles << TestDocument::create("file.cpp", original, expected); testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(testFiles); QuickFixTestCase(testFiles, &factory);
test.run(&factory);