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 <edward.welbourne@qt.io>
This commit is contained in:
parent
c038fa9e77
commit
79cf895c70
@ -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());
|
||||
}
|
||||
|
@ -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());
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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"));
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user