summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qlocale
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-10-19 14:52:19 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-23 14:13:42 +0000
commit15b5b3b3f01e400e46fe67babe593ede373dac4b (patch)
tree823f6a27092b9647dbe1f4a9004c99e9975e71c7 /tests/auto/corelib/tools/qlocale
parent726fed0d67013cbfac7921d3d4613ca83406fb0f (diff)
Add flags to omit/reject padding in scientific notation exponents
The EcmaScript format for printing doubles in exponent form differs from Qt's format only in this aspect. EcmaScript explicitly prohibits leading zeroes in exponents. It is thus worthwhile to add those flags in order to be able to generate and parse doubles in compliance with EcmaScript. [ChangeLog][QtCore][QLocale] Additional flags in QLocale::NumberOption allow generating and parsing doubles in EcmaScript compliant format. Change-Id: Ia7b82c2e67bb8b80bd890014ff5cd4563faf2a03 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'tests/auto/corelib/tools/qlocale')
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 683f7490e5..ee45f95d83 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1698,6 +1698,20 @@ void tst_QLocale::numberOptions()
QLocale locale2 = locale;
QCOMPARE(locale2.numberOptions(), QLocale::RejectGroupSeparator);
+
+ QCOMPARE(locale.toString(12.4, 'e', 2), QString("1.24e+01"));
+ locale.setNumberOptions(QLocale::OmitLeadingZeroInExponent);
+ QCOMPARE(locale.numberOptions(), QLocale::OmitLeadingZeroInExponent);
+ QCOMPARE(locale.toString(12.4, 'e', 2), QString("1.24e+1"));
+
+ locale.toDouble(QString("1.24e+01"), &ok);
+ QVERIFY(ok);
+ locale.setNumberOptions(QLocale::RejectLeadingZeroInExponent);
+ QCOMPARE(locale.numberOptions(), QLocale::RejectLeadingZeroInExponent);
+ locale.toDouble(QString("1.24e+1"), &ok);
+ QVERIFY(ok);
+ locale.toDouble(QString("1.24e+01"), &ok);
+ QVERIFY(!ok);
}
void tst_QLocale::negativeNumbers()