From 9680b8434e7eeb6a7053e352757791a12b59d27f Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 2 Aug 2023 12:47:18 +0200 Subject: [PATCH] Tests: Simplify return statements Change-Id: I9609609f0f880654b73e8930cd05818ddf9b7152 Reviewed-by: Orgad Shaneh --- .../auto/cplusplus/checksymbols/tst_checksymbols.cpp | 2 +- .../auto/cplusplus/preprocessor/tst_preprocessor.cpp | 11 +++-------- .../extensionsystem/pluginspec/tst_pluginspec.cpp | 4 ++-- .../qml/qmldesigner/coretests/testrewriterview.cpp | 3 +-- tests/auto/utils/multicursor/tst_multicursor.cpp | 2 +- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp index e73468db799..0e0705c5e56 100644 --- a/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp +++ b/tests/auto/cplusplus/checksymbols/tst_checksymbols.cpp @@ -144,7 +144,7 @@ public: if (result.column == column) return result; } - return Use(); + return {}; } CheckSymbols::Future future; diff --git a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp index d9fce5e2f23..54ceed08ca0 100644 --- a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp +++ b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp @@ -21,7 +21,7 @@ QByteArray loadSource(const QString &fileName) QFile inf(QLatin1String(SRCDIR) + QLatin1Char('/') + fileName); if (!inf.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug("Cannot open \"%s\"", fileName.toUtf8().constData()); - return QByteArray(); + return {}; } QTextStream ins(&inf); @@ -194,11 +194,7 @@ public: else dir = QFileInfo(currentFileName).dir(); const QFileInfo inc(dir, includedFileName); - if (inc.exists()) { - return inc.filePath(); - } else { - return QString(); - } + return inc.exists() ? inc.filePath() : QString(); } QString resolveGlobally(const QString ¤tFileName) const @@ -208,8 +204,7 @@ public: if (f.exists()) return f.filePath(); } - - return QString(); + return {}; } void setIncludePaths(const QStringList &includePaths) diff --git a/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp b/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp index abf5bd5c068..762142b95ee 100644 --- a/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp +++ b/tests/auto/extensionsystem/pluginspec/tst_pluginspec.cpp @@ -20,13 +20,13 @@ static QJsonObject metaData(const QString &fileName) QFile f(fileName); if (!f.open(QIODevice::ReadOnly)) { qWarning() << "Could not open" << fileName; - return QJsonObject(); + return {}; } QJsonParseError error; QJsonDocument doc = QJsonDocument::fromJson(f.readAll(), &error); if (error.error != QJsonParseError::NoError) { qWarning() << "Could not parse" << fileName << ":" << error.errorString(); - return QJsonObject(); + return {}; } return doc.object(); } diff --git a/tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp b/tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp index 0f708da693e..4dc37a3b691 100644 --- a/tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp +++ b/tests/auto/qml/qmldesigner/coretests/testrewriterview.cpp @@ -57,8 +57,7 @@ VariantProperty TestModelToTextMerger::findAddedVariantProperty(const VariantPro return property.toVariantProperty(); } } - - return VariantProperty(); + return {}; } TestRewriterView::TestRewriterView(ExternalDependenciesInterface &externalDependencies, diff --git a/tests/auto/utils/multicursor/tst_multicursor.cpp b/tests/auto/utils/multicursor/tst_multicursor.cpp index 4068d47f1fe..f873af143c7 100644 --- a/tests/auto/utils/multicursor/tst_multicursor.cpp +++ b/tests/auto/utils/multicursor/tst_multicursor.cpp @@ -57,7 +57,7 @@ public: QTextCursor toTextCursor(QTextDocument *doc) { if (p.first < 0) - return QTextCursor(); + return {}; QTextCursor c(doc); c.setPosition(p.second); c.setPosition(p.first, QTextCursor::KeepAnchor);