summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-07-14 17:10:14 +0200
committerMarc Mutz <[email protected]>2025-07-15 00:25:35 +0200
commitece0b02798d9206cafcf123b83c20891856ad342 (patch)
treedb32dadbf3a2e4cfce74788e18f8db42f3ef0151
parentb9f6a1b113d8f26210da5c3194f0f790883761fe (diff)
tst_QLocale: check negative/positiveSign() is never == u'\0'
Code in QTextStream assumes this, so we need to make sure it holds for all locales. The test is modelled after testNames(), which is from 2012, so should be available in all active branches, incl. 5.15 ESM. Task-number: QTBUG-138475 Pick-to: 6.10 6.9 6.8 6.5 5.15 Change-Id: Ib1552bb0e75a35676e1fd2b3901784654dd76998 Reviewed-by: Edward Welbourne <[email protected]>
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index bfc6074689b..50e17728cf3 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -78,6 +78,9 @@ private slots:
void negativeZero_data();
void negativeZero();
+ void signsNeverCompareEqualToNullCharacter_data() { testNames_data(); }
+ void signsNeverCompareEqualToNullCharacter();
+
void dayOfWeek();
void dayOfWeek_data();
void formatDate();
@@ -2114,6 +2117,19 @@ void tst_QLocale::negativeZero()
QCOMPARE(locale.toString(std::copysign(0.0, -1.0)), expect);
}
+void tst_QLocale::signsNeverCompareEqualToNullCharacter() // otherwise QTextStream has a problem
+{
+ QFETCH(QLocale::Language, language);
+ QFETCH(const QLocale::Territory, country);
+
+ if (language == QLocale::AnyLanguage && country == QLocale::AnyTerritory)
+ language = QLocale::C;
+
+ const QLocale loc(language, country);
+ QCOMPARE_NE(loc.negativeSign(), QChar());
+ QCOMPARE_NE(loc.positiveSign(), QChar());
+}
+
void tst_QLocale::dayOfWeek_data()
{
QTest::addColumn<QDate>("date");