tst_QByteArray/tst_QString: use new QtMiscUtils::toAsciiUpper()

... in lieu of <cctype>'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 <marten.nordheim@qt.io>
(cherry picked from commit 78db5cb6439070f43422cbda3a562b46c8fc5cf9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2022-12-20 10:27:38 +01:00 committed by Qt Cherry-pick Bot
parent 10772b6f7b
commit 43f6e10a7c
2 changed files with 3 additions and 3 deletions

View File

@ -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())

View File

@ -28,11 +28,11 @@
#include <qlocale.h>
#include <locale.h>
#include <qhash.h>
#include <private/qtools_p.h>
#include <string>
#include <algorithm>
#include <limits>
#include <ctype.h>
#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())