diff options
author | Liang Qi <liang.qi@qt.io> | 2020-02-13 09:14:09 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-02-13 18:31:40 +0100 |
commit | 6b2535ea15cdbdb2355416b604f072fc13ff36b2 (patch) | |
tree | 4bf1560bab77c8b315850c5337ba31a0ea87b5f0 /tests/auto/corelib/text/qlocale/tst_qlocale.cpp | |
parent | 54c2cebabdda0280b8443c6947b6fee02445e138 (diff) | |
parent | 67491e2df5357706dbf88ddaf1f030ff095b4528 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
examples/widgets/graphicsview/boxes/scene.h
src/corelib/Qt5CoreMacros.cmake
src/corelib/Qt6CoreMacros.cmake
src/network/ssl/qsslsocket.cpp
src/network/ssl/qsslsocket.h
src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
src/testlib/CMakeLists.txt
src/testlib/.prev_CMakeLists.txt
tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp
Disabled building manual tests with CMake for now, because qmake
doesn't do it, and it confuses people.
Done-With: Alexandru Croitor <alexandru.croitor@qt.io>
Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io>
Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
Diffstat (limited to 'tests/auto/corelib/text/qlocale/tst_qlocale.cpp')
-rw-r--r-- | tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index f19b66be37..e4144a376e 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -1887,14 +1887,16 @@ void tst_QLocale::toDateTime() // Format number string according to system locale settings. // Expected in format is US "1,234.56". -QString systemLocaleFormatNumber(const QString &numberString) +QString systemLocaleFormatNumber(QString &&numberString) { QLocale locale = QLocale::system(); - QString numberStringCopy = numberString; - return numberStringCopy.replace(QChar(','), QChar('G')) - .replace(QChar('.'), QChar('D')) - .replace(QChar('G'), locale.groupSeparator()) - .replace(QChar('D'), locale.decimalPoint()); + QString numberStringMunged = + numberString.replace(QChar(','), QChar('G')).replace(QChar('.'), QChar('D')); + if (locale.numberOptions() & QLocale::OmitGroupSeparator) + numberStringMunged.remove(QLatin1Char('G')); + else + numberStringMunged.replace(QChar('G'), locale.groupSeparator()); + return numberStringMunged.replace(QChar('D'), locale.decimalPoint()); } void tst_QLocale::macDefaultLocale() @@ -1917,12 +1919,14 @@ void tst_QLocale::macDefaultLocale() // independently of the locale. Verify that they have one of the // allowed values and are not the same. QVERIFY(locale.decimalPoint() == QChar('.') || locale.decimalPoint() == QChar(',')); - QVERIFY(locale.groupSeparator() == QChar(',') - || locale.groupSeparator() == QChar('.') - || locale.groupSeparator() == QChar('\xA0') // no-breaking space - || locale.groupSeparator() == QChar('\'') - || locale.groupSeparator() == QChar()); - QVERIFY(locale.decimalPoint() != locale.groupSeparator()); + if (!(locale.numberOptions() & QLocale::OmitGroupSeparator)) { + QVERIFY(locale.groupSeparator() == QChar(',') + || locale.groupSeparator() == QChar('.') + || locale.groupSeparator() == QChar('\xA0') // no-breaking space + || locale.groupSeparator() == QChar('\'') + || locale.groupSeparator() == QChar()); + QVERIFY(locale.decimalPoint() != locale.groupSeparator()); + } // make sure we are using the system to parse them QCOMPARE(locale.toString(1234.56), systemLocaleFormatNumber(QString("1,234.56"))); @@ -2056,6 +2060,8 @@ void tst_QLocale::windowsDefaultLocale() setWinLocaleInfo(LOCALE_SLONGDATE, longDateFormat); const QString shortTimeFormat = QStringLiteral("h^m^s"); setWinLocaleInfo(LOCALE_SSHORTTIME, shortTimeFormat); + const QString longTimeFormat = QStringLiteral("HH%mm%ss"); + setWinLocaleInfo(LOCALE_STIMEFORMAT, longTimeFormat); QSystemLocale dummy; // to provoke a refresh of the system locale QLocale locale = QLocale::system(); @@ -2069,7 +2075,7 @@ void tst_QLocale::windowsDefaultLocale() QCOMPARE(locale.dateTimeFormat(QLocale::ShortFormat), shortDateFormat + QLatin1Char(' ') + shortTimeFormat); const QString expectedLongDateTimeFormat - = longDateFormat + QLatin1Char(' ') + QStringLiteral("h:mm:ss AP"); + = longDateFormat + QLatin1Char(' ') + longTimeFormat; QCOMPARE(locale.dateTimeFormat(QLocale::LongFormat), expectedLongDateTimeFormat); // make sure we are using the system to parse them @@ -2083,7 +2089,7 @@ void tst_QLocale::windowsDefaultLocale() QCOMPARE(locale.toString(QTime(1,2,3), QLocale::ShortFormat), expectedFormattedShortTime); QCOMPARE(locale.toString(QTime(1,2,3), QLocale::NarrowFormat), locale.toString(QTime(1,2,3), QLocale::ShortFormat)); - const QString expectedFormattedLongTime = QStringLiteral("1:02:03 AM"); + const QString expectedFormattedLongTime = QStringLiteral("01%02%03"); QCOMPARE(locale.toString(QTime(1,2,3), QLocale::LongFormat), expectedFormattedLongTime); QCOMPARE(locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::ShortFormat), QStringLiteral("1*12*1974 ") + expectedFormattedShortTime); @@ -2091,7 +2097,6 @@ void tst_QLocale::windowsDefaultLocale() locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::ShortFormat)); QCOMPARE(locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::LongFormat), QStringLiteral("1@12@1974 ") + expectedFormattedLongTime); - QCOMPARE(locale.toString(QTime(1,2,3), QLocale::LongFormat), expectedFormattedLongTime); } #endif // Q_OS_WIN but !Q_OS_WINRT |