summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-01-15 16:54:20 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-01-30 17:57:40 +0100
commit264ed73052513015caafaf146286cf63aaa68b03 (patch)
treed24647e7d078388a9d57727a31f68eb3227c1206 /tests/auto/corelib/text/qlocale/tst_qlocale.cpp
parent47d94dab0fbc428e5c3401c411ac01a05e5e851f (diff)
Move old tst_QLocale::negativeZero() to tst_QString::number()
It was more complex than it needed to be and was a test of QString, not of QLocale. This leaves tst_QLocale::negativeZero() available to now test how QLocale handles negative zero. Change-Id: Ic9aae250c29f579e6d60fba8404b38673a3b489f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib/text/qlocale/tst_qlocale.cpp')
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index f56414331a..f19b66be37 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -59,6 +59,7 @@
#endif
Q_DECLARE_METATYPE(QLocale::FormatType)
+Q_DECLARE_METATYPE(QStringView)
class tst_QLocale : public QObject
{
@@ -95,6 +96,7 @@ private slots:
void long_long_conversion_extra();
void testInfAndNan();
void fpExceptions();
+ void negativeZero_data();
void negativeZero();
void dayOfWeek();
void dayOfWeek_data();
@@ -1422,13 +1424,29 @@ void tst_QLocale::fpExceptions()
#endif
}
+void tst_QLocale::negativeZero_data()
+{
+ QTest::addColumn<QLocale::Language>("language");
+ QTest::addColumn<QLocale::Script>("script");
+ QTest::addColumn<QLocale::Country>("territory");
+ QTest::addColumn<QStringView>("expect");
+
+ QTest::newRow("C")
+ << QLocale::C << QLocale::AnyScript << QLocale::AnyCountry
+ << QStringView(u"0");
+ QTest::newRow("Arabic")
+ << QLocale::Arabic << QLocale::ArabicScript << QLocale::AnyCountry
+ << QStringView(u"\u0660");
+}
+
void tst_QLocale::negativeZero()
{
- double negativeZero( 0.0 ); // Initialise to zero.
- uchar *ptr = (uchar *)&negativeZero;
- ptr[QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 7] = 0x80;
- QString s = QString::number(negativeZero);
- QCOMPARE(s, QString("0"));
+ QFETCH(QLocale::Language, language);
+ QFETCH(QLocale::Script, script);
+ QFETCH(QLocale::Country, territory);
+ QFETCH(QStringView, expect);
+ QLocale locale(language, script, territory);
+ QCOMPARE(locale.toString(std::copysign(0.0, -1.0)), expect);
}
void tst_QLocale::dayOfWeek_data()