From 43f6e10a7c3acb02e268510a61ea61a8d482afa9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 20 Dec 2022 10:27:38 +0100 Subject: [PATCH] tst_QByteArray/tst_QString: use new QtMiscUtils::toAsciiUpper() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... in lieu of 's toupper(), which is locale-dependent, and out-of-line. The code doesn't run into the toupper(i) issue in the Türkiye locale, because we don't run tests in that locale and because 'i' is not a valid format specifier, but don't let the next reader of the code guess when the use of toAsciiUpper() provides unambiguous guidance. Task-number: QTBUG-109235 Change-Id: I8988f5190441e1ae5cb57370952cda70ca6bb658 Reviewed-by: Mårten Nordheim (cherry picked from commit 78db5cb6439070f43422cbda3a562b46c8fc5cf9) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp | 2 +- tests/auto/corelib/text/qstring/tst_qstring.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 34bee7bce8b..842f5826eae 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -1256,7 +1256,7 @@ void tst_QByteArray::number_double_data() QTest::addRow("%s, format '%c', precision %d", title, datum.f, datum.p) << datum.d << datum.f << datum.p << ba; if (datum.f != 'f') { // Also test uppercase format - datum.f = toupper(datum.f); + datum.f = QtMiscUtils::toAsciiUpper(datum.f); QByteArray upper = ba.toUpper(); QByteArray upperTitle = QByteArray(title); if (!datum.optTitle.isEmpty()) diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 18fe85a3387..fdde5b0e7f2 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -28,11 +28,11 @@ #include #include #include +#include #include #include #include -#include #include "../shared/test_number_shared.h" #include "../../../../shared/localechange.h" @@ -5778,7 +5778,7 @@ void tst_QString::number_double_data() QTest::addRow("%s, format '%c', precision %d", title, datum.f, datum.p) << datum.d << datum.f << datum.p << datum.expected.toString(); if (datum.f != 'f') { // Also test uppercase format - datum.f = toupper(datum.f); + datum.f = QtMiscUtils::toAsciiUpper(datum.f); QString upper = datum.expected.toString().toUpper(); QString upperTitle = QString::fromLatin1(title); if (!datum.optTitle.isEmpty())