From 0f5a7217617e30bfb06991390b4bf673c67ed4aa Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 13 Oct 2015 13:06:26 +0200 Subject: Tests: Fix single-character string literals. Use character literals where applicable. Change-Id: Ib0e618752fbc762a73a0a91c43efab61ef2c9687 Reviewed-by: Ulf Hermann Reviewed-by: Simon Hausmann --- .../qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp | 2 +- tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp | 2 +- tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 2 +- tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp | 2 +- tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp | 9 ++++++--- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 2 +- tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp | 4 ++-- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 4 ++-- tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp | 2 +- tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 6 +++--- tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp | 11 +++++++---- tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp | 2 +- .../qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp | 4 ++-- 13 files changed, 29 insertions(+), 23 deletions(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index 4ab1ac0a4c..98ef590317 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -98,7 +98,7 @@ bool tst_QQmlDebuggingEnabler::init(bool blockMode, bool qmlscene, int portFrom, if (qmlscene) { process->start(QStringList() << QLatin1String("-qmljsdebugger=port:") + - QString::number(portFrom) + QLatin1String(",") + QString::number(portTo) + + QString::number(portFrom) + QLatin1Char(',') + QString::number(portTo) + QLatin1String(blockMode ? ",block": "") << testFile(QLatin1String("test.qml"))); } else { diff --git a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp index e01ea73e1b..52d676ef3c 100644 --- a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp +++ b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp @@ -110,7 +110,7 @@ QJsonValue tst_qjsonbinding::valueFromJson(const QByteArray &json) // QJsonDocument::fromJson() only handles objects and arrays... // Wrap the JSON inside a dummy object and extract the value. - QByteArray wrappedJson = "{\"prop\":" + json + "}"; + QByteArray wrappedJson = "{\"prop\":" + json + '}'; doc = QJsonDocument::fromJson(wrappedJson); Q_ASSERT(doc.isObject()); return doc.object().value("prop"); diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index bea44cb6e3..bf9bd18807 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -2436,7 +2436,7 @@ void tst_QJSValue::prettyPrinter() QFETCH(QString, function); QFETCH(QString, expected); QJSEngine eng; - QJSValue val = eng.evaluate("(" + function + ")"); + QJSValue val = eng.evaluate(QLatin1Char('(') + function + QLatin1Char(')')); QVERIFY(val.isCallable()); QString actual = val.toString(); QSKIP("Function::toString() doesn't give the whole function on v4"); diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp index 2a534b5913..28d687bd1c 100644 --- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -84,7 +84,7 @@ void tst_qmlplugindump::builtins() if (dumper.error() != QProcess::UnknownError || dumper.exitStatus() != QProcess::NormalExit) { qWarning() << QString("Error while running '%1 %2'").arg( - qmlplugindumpPath, args.join(QLatin1String(" "))); + qmlplugindumpPath, args.join(QLatin1Char(' '))); } if (dumper.error() == QProcess::FailedToStart) { diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp index 6b2add309a..6f2febaccf 100644 --- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp +++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp @@ -73,7 +73,7 @@ namespace { QString toString(const QQmlDirParser::Plugin &p) { - return p.name + "|" + p.path; + return p.name + QLatin1Char('|') + p.path; } QStringList toStringList(const QList &plugins) @@ -88,7 +88,9 @@ namespace { QString toString(const QQmlDirParser::Component &c) { - return c.typeName + "|" + c.fileName + "|" + QString::number(c.majorVersion) + "|" + QString::number(c.minorVersion) + "|" + (c.internal ? "true" : "false"); + return c.typeName + QLatin1Char('|') + c.fileName + QLatin1Char('|') + + QString::number(c.majorVersion) + QLatin1Char('|') + QString::number(c.minorVersion) + + QLatin1Char('|') + (c.internal ? "true" : "false"); } QStringList toStringList(const QQmlDirComponents &components) @@ -104,7 +106,8 @@ namespace { QString toString(const QQmlDirParser::Script &s) { - return s.nameSpace + "|" + s.fileName + "|" + QString::number(s.majorVersion) + "|" + QString::number(s.minorVersion); + return s.nameSpace + QLatin1Char('|') + s.fileName + QLatin1Char('|') + + QString::number(s.majorVersion) + '|' + QString::number(s.minorVersion); } QStringList toStringList(const QList &scripts) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 87815c8821..f238bf6b90 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -7330,7 +7330,7 @@ void tst_qqmlecmascript::sequenceSort_data() for (size_t t=0 ; t < sizeof(types)/sizeof(types[0]) ; ++t) { for (size_t s=0 ; s < sizeof(sort)/sizeof(sort[0]) ; ++s) { for (int c=0 ; c < 2 ; ++c) { - QString testName = QLatin1String(types[t]) + QLatin1String("_") + QLatin1String(sort[s]); + QString testName = QLatin1String(types[t]) + QLatin1Char('_') + QLatin1String(sort[s]); QString fnName = QLatin1String("test_") + testName; bool useComparer = c != 0; testName += useComparer ? QLatin1String("[custom]") : QLatin1String("[default]"); diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp index 4f559b0d33..2f581e296a 100644 --- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -96,8 +96,8 @@ private: QList actual; \ for (int ii = 0; ii < errors.count(); ++ii) { \ const QQmlError &error = errors.at(ii); \ - QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ - QByteArray::number(error.column()) + ":" + \ + QByteArray errorStr = QByteArray::number(error.line()) + ':' + \ + QByteArray::number(error.column()) + ':' + \ error.description().toUtf8(); \ actual << errorStr; \ } \ diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 54e9c361e4..3c7584bfa1 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -282,8 +282,8 @@ private: QList errors = component.errors(); \ for (int ii = 0; ii < errors.count(); ++ii) { \ const QQmlError &error = errors.at(ii); \ - QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ - QByteArray::number(error.column()) + ":" + \ + QByteArray errorStr = QByteArray::number(error.line()) + ':' + \ + QByteArray::number(error.column()) + ':' + \ error.description().toUtf8(); \ actual << errorStr; \ } \ diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 519ee7ac26..d26c1c584b 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -625,7 +625,7 @@ void tst_qqmllistmodel::enumerate() int expectedStringCount = sizeof(expectedStrings) / sizeof(expectedStrings[0]); - QStringList r = item->property("result").toString().split(":"); + QStringList r = item->property("result").toString().split(QLatin1Char(':')); int matchCount = 0; for (int i=0 ; i < expectedStringCount ; ++i) { diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index ba3f72f2c1..030af07a70 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -676,7 +676,7 @@ void tst_qqmllocale::addDateTimeFormatData(const QString &l) int i = 0; while (formats[i]) { QByteArray t(locale); - t += " "; + t += ' '; t += formats[i]; QTest::newRow(t.constData()) << l << QString(formats[i]); ++i; @@ -768,7 +768,7 @@ void tst_qqmllocale::addDateFormatData(const QString &l) int i = 0; while (formats[i]) { QByteArray t(locale); - t += " "; + t += ' '; t += formats[i]; QTest::newRow(t.constData()) << l << QString(formats[i]); ++i; @@ -860,7 +860,7 @@ void tst_qqmllocale::addTimeFormatData(const QString &l) int i = 0; while (formats[i]) { QByteArray t(locale); - t += " "; + t += ' '; t += formats[i]; QTest::newRow(t.constData()) << l << QString(formats[i]); ++i; diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index 0e326abad9..77fc67a1ac 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -110,8 +110,8 @@ void tst_qqmlmoduleplugin::initTestCase() QList actual; \ for (int ii = 0; ii < errors.count(); ++ii) { \ const QQmlError &error = errors.at(ii); \ - QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ - QByteArray::number(error.column()) + ":" + \ + QByteArray errorStr = QByteArray::number(error.line()) + ':' + \ + QByteArray::number(error.column()) + ':' + \ error.description().toUtf8(); \ actual << errorStr; \ } \ @@ -202,8 +202,11 @@ void tst_qqmlmoduleplugin::incorrectPluginCase() caseSensitive = false; QString libname = "PluGin.dll"; #endif - if (!caseSensitive) - expectedError = QLatin1String("plugin cannot be loaded for module \"org.qtproject.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("org/qtproject/WrongCase/" + libname) + QLatin1String("\""); + if (!caseSensitive) { + expectedError = QLatin1String("plugin cannot be loaded for module \"org.qtproject.WrongCase\": File name case mismatch for \"") + + QDir(m_importsDirectory).filePath("org/qtproject/WrongCase/" + libname) + + QLatin1Char('"'); + } #endif QCOMPARE(errors.at(0).description(), expectedError); diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp index 47bf151a37..68f85daacd 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -621,7 +621,7 @@ void tst_qqmlxmlhttprequest::send_options() QVERIFY(!object.isNull()); QString url = server.baseUrl().toString(); if (url_suffix != "/") - url.append("/"); + url.append(QLatin1Char('/')); if (!url_suffix.isEmpty()) url.append(url_suffix); object->setProperty("url", url); diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index dc6e2fa561..aca809a137 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -93,8 +93,8 @@ void tst_qquickfolderlistmodel::checkNoErrors(const QQmlComponent& component) QList errors = component.errors(); for (int ii = 0; ii < errors.count(); ++ii) { const QQmlError &error = errors.at(ii); - QByteArray errorStr = QByteArray::number(error.line()) + ":" + - QByteArray::number(error.column()) + ":" + + QByteArray errorStr = QByteArray::number(error.line()) + ':' + + QByteArray::number(error.column()) + ':' + error.description().toUtf8(); qWarning() << errorStr; } -- cgit v1.2.3