diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-12-30 19:44:42 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-01-07 14:19:33 +0100 |
commit | 0bd59178679ea1f573b484e5f2baf178352c44ef (patch) | |
tree | 5d4a19d2556c9d41bc2a1d4f42510c92a5107d66 /src/plugins/cpptools/cppcompletion_test.cpp | |
parent | c7f3ac407394d3c4d7fe817a6a913cd3256c37e5 (diff) | |
download | qt-creator-0bd59178679ea1f573b484e5f2baf178352c44ef.tar.gz |
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: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppcompletion_test.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcompletion_test.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 173181c412..83387eaa70 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -63,6 +63,9 @@ public: CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray()) : m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0) { + QVERIFY(succeededSoFar()); + m_succeededSoFar = false; + m_source = sourceText; m_position = m_source.indexOf('@'); QVERIFY(m_position != -1); @@ -89,6 +92,8 @@ public: if (!textToInsert.isEmpty()) insertText(textToInsert); + + m_succeededSoFar = true; } QStringList getCompletions(bool *replaceAccessOperator = 0) const @@ -162,6 +167,7 @@ void CppToolsPlugin::test_completion_basic_1() " @\n" "}"; CompletionTestCase test(source); + QVERIFY(test.succeededSoFar()); QStringList basicCompletions = test.getCompletions(); QVERIFY(!basicCompletions.contains(QLatin1String("foo"))); @@ -189,6 +195,7 @@ void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_8737() "}\n" ; CompletionTestCase test(source, "a_c"); + QVERIFY(test.succeededSoFar()); QStringList completions = test.getCompletions(); @@ -214,9 +221,9 @@ void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_9236() "};\n" ; CompletionTestCase test(source, "ret"); + QVERIFY(test.succeededSoFar()); QStringList completions = test.getCompletions(); - QVERIFY(completions.size() >= 2); QCOMPARE(completions.at(0), QLatin1String("return")); QCOMPARE(completions.at(1), QLatin1String("rETUCASE")); @@ -233,9 +240,9 @@ void CppToolsPlugin::test_completion_template_function() QFETCH(QStringList, expectedCompletions); CompletionTestCase test(code); + QVERIFY(test.succeededSoFar()); QStringList actualCompletions = test.getCompletions(); - QString errorPattern(QLatin1String("Completion not found: %1")); foreach (const QString &completion, expectedCompletions) { QByteArray errorMessage = errorPattern.arg(completion).toUtf8(); @@ -290,6 +297,7 @@ void CppToolsPlugin::test_completion() QFETCH(QStringList, expectedCompletions); CompletionTestCase test(code, prefix); + QVERIFY(test.succeededSoFar()); QStringList actualCompletions = test.getCompletions(); actualCompletions.sort(); @@ -2092,6 +2100,7 @@ void CppToolsPlugin::test_completion_member_access_operator() QFETCH(bool, expectedReplaceAccessOperator); CompletionTestCase test(code, prefix); + QVERIFY(test.succeededSoFar()); bool replaceAccessOperator = false; QStringList completions = test.getCompletions(&replaceAccessOperator); |