diff options
author | Sona Kurazyan <[email protected]> | 2022-04-26 16:33:09 +0200 |
---|---|---|
committer | Sona Kurazyan <[email protected]> | 2022-04-28 11:15:11 +0200 |
commit | 79cf895c700f2a700479eae10cf538d0860e1d29 (patch) | |
tree | 8b32cd14f396e922faf855751290f22a0ea8a355 | |
parent | c038fa9e774d8531ccb975e6ca1541358830847e (diff) |
QtTestLib: stop using QLatin1Char constructor for creating char literals
Required for porting away from QLatin1Char/QLatin1String in scope of
QTBUG-98434.
Change-Id: I3debae5f481037958bfb65caabca97a0d4681eb9
Reviewed-by: Edward Welbourne <[email protected]>
-rw-r--r-- | src/testlib/qappletestlogger.cpp | 2 | ||||
-rw-r--r-- | src/testlib/qjunittestlogger.cpp | 4 | ||||
-rw-r--r-- | src/testlib/qplaintestlogger.cpp | 9 | ||||
-rw-r--r-- | src/testlib/qtaptestlogger.cpp | 2 | ||||
-rw-r--r-- | src/testlib/qtestcase.cpp | 12 | ||||
-rw-r--r-- | src/testlib/qtestlog.cpp | 6 |
6 files changed, 17 insertions, 18 deletions
diff --git a/src/testlib/qappletestlogger.cpp b/src/testlib/qappletestlogger.cpp index 4de0045af5b..95cf67667c1 100644 --- a/src/testlib/qappletestlogger.cpp +++ b/src/testlib/qappletestlogger.cpp @@ -140,7 +140,7 @@ void QAppleTestLogger::addIncident(IncidentTypes type, const char *description, QString message = testIdentifier(); if (qstrlen(description)) - message += QLatin1Char('\n') % QString::fromLatin1(description); + message += u'\n' % QString::fromLatin1(description); AppleUnifiedLogger::messageHandler(messageData.messageType, context, message, subsystem()); } diff --git a/src/testlib/qjunittestlogger.cpp b/src/testlib/qjunittestlogger.cpp index c185e652c9f..fa817efd4f5 100644 --- a/src/testlib/qjunittestlogger.cpp +++ b/src/testlib/qjunittestlogger.cpp @@ -272,8 +272,8 @@ void QJUnitTestLogger::addFailure(QTest::LogElementType elementType, failureElement->addAttribute(QTest::AI_Type, failureType); // Assume the first line is the message, and the remainder are details - QString message = failureDescription.section(QLatin1Char('\n'), 0, 0); - QString details = failureDescription.section(QLatin1Char('\n'), 1); + QString message = failureDescription.section(u'\n', 0, 0); + QString details = failureDescription.section(u'\n', 1); failureElement->addAttribute(QTest::AI_Message, message.toUtf8().constData()); diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 4e38a2edce5..aa041edb663 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -162,7 +162,7 @@ namespace QTest { // Replace insignificant digits before the decimal point with zeros. beforeDecimalPoint.chop(beforeRemove); for (int i = 0; i < beforeRemove; ++i) { - beforeDecimalPoint.append(QLatin1Char('0')); + beforeDecimalPoint.append(u'0'); } int afterUse = significantDigits - beforeUse; @@ -172,9 +172,8 @@ namespace QTest { ++afterUse; int i = 0; - while (i < afterDecimalPoint.length() && afterDecimalPoint.at(i) == QLatin1Char('0')) { + while (i < afterDecimalPoint.length() && afterDecimalPoint.at(i) == u'0') ++i; - } afterUse += i; } @@ -182,8 +181,8 @@ namespace QTest { int afterRemove = afterDecimalPoint.length() - afterUse; afterDecimalPoint.chop(afterRemove); - QChar separator = QLatin1Char(','); - QChar decimalPoint = QLatin1Char('.'); + QChar separator = u','; + QChar decimalPoint = u'.'; // insert thousands separators int length = beforeDecimalPoint.length(); diff --git a/src/testlib/qtaptestlogger.cpp b/src/testlib/qtaptestlogger.cpp index 2f64752aab3..45b3d2f9a08 100644 --- a/src/testlib/qtaptestlogger.cpp +++ b/src/testlib/qtaptestlogger.cpp @@ -337,7 +337,7 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description, QString expected; QString actual; const auto parenthesize = [&match](QLatin1String key) -> QString { - return QLatin1String(" (") % match.captured(key) % QLatin1Char(')'); + return QLatin1String(" (") % match.captured(key) % u')'; }; const QString actualExpression = parenthesize(QLatin1String("actualexpression")); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index caaf22508db..b4d1ee402fa 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2328,7 +2328,7 @@ QSharedPointer<QTemporaryDir> QTest::qExtractTestData(const QString &dirName) return result; const QString dataPath = tempDir->path(); - const QString resourcePath = QLatin1Char(':') + dirName; + const QString resourcePath = u':' + dirName; const QFileInfo fileInfo(resourcePath); if (!fileInfo.isDir()) { @@ -2346,7 +2346,7 @@ QSharedPointer<QTemporaryDir> QTest::qExtractTestData(const QString &dirName) QFileInfo fileInfo = it.nextFileInfo(); if (!fileInfo.isDir()) { - const QString destination = dataPath + QLatin1Char('/') + QStringView{fileInfo.filePath()}.mid(resourcePath.length()); + const QString destination = dataPath + u'/' + QStringView{fileInfo.filePath()}.mid(resourcePath.length()); QFileInfo destinationFileInfo(destination); QDir().mkpath(destinationFileInfo.path()); if (!QFile::copy(fileInfo.filePath(), destination)) { @@ -2391,7 +2391,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co } #endif // Q_OS_WIN else if (QTestLog::verboseLevel() >= 2) { - const QString candidate = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QLatin1Char('/') + base); + const QString candidate = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + u'/' + base); QTestLog::info(qPrintable( QLatin1String("testdata %1 not found relative to test binary [%2]; " "checking next location").arg(base, candidate)), @@ -2456,7 +2456,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co // 5. Try current directory if (found.isEmpty()) { - const QString candidate = QDir::currentPath() + QLatin1Char('/') + base; + const QString candidate = QDir::currentPath() + u'/' + base; if (QFileInfo::exists(candidate)) { found = candidate; } else if (QTestLog::verboseLevel() >= 2) { @@ -2469,7 +2469,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co // 6. Try main source directory if (found.isEmpty()) { - const QString candidate = QTest::mainSourcePath % QLatin1Char('/') % base; + const QString candidate = QTest::mainSourcePath % u'/' % base; if (QFileInfo::exists(candidate)) { found = candidate; } else if (QTestLog::verboseLevel() >= 2) { @@ -2482,7 +2482,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co // 7. Try the supplied source directory if (found.isEmpty() && sourcedir) { - const QString candidate = QFile::decodeName(sourcedir) % QLatin1Char('/') % base; + const QString candidate = QFile::decodeName(sourcedir) % u'/' % base; if (QFileInfo::exists(candidate)) { found = candidate; } else if (QTestLog::verboseLevel() >= 2) { diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 4f0e3a43bc4..e87527e57aa 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -148,7 +148,7 @@ namespace QTest { // ignore an optional whitespace at the end of str // (the space was added automatically by ~QDebug() until Qt 5.3, // so autotests still might expect it) - if (expected.endsWith(QLatin1Char(' '))) + if (expected.endsWith(u' ')) return actual == QStringView{expected}.left(expected.length() - 1); return false; @@ -328,10 +328,10 @@ void QTestLog::printUnhandledIgnoreMessages() QTest::IgnoreResultList *list = QTest::ignoreResultList; while (list) { if (list->pattern.userType() == QMetaType::QString) { - message = QStringLiteral("Did not receive message: \"") + list->pattern.toString() + QLatin1Char('"'); + message = QStringLiteral("Did not receive message: \"") + list->pattern.toString() + u'"'; } else { #if QT_CONFIG(regularexpression) - message = QStringLiteral("Did not receive any message matching: \"") + list->pattern.toRegularExpression().pattern() + QLatin1Char('"'); + message = QStringLiteral("Did not receive any message matching: \"") + list->pattern.toRegularExpression().pattern() + u'"'; #endif } FOREACH_TEST_LOGGER |