diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2023-05-09 13:11:01 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2023-05-10 17:30:45 +0200 |
commit | 74b377313e98e0fa745e21524e220c9619dd8bb2 (patch) | |
tree | 070ef081d89a6e8bd00d231d988fdee077e2a81f /tests/auto/corelib/text/qlocale | |
parent | 36e59db1bb08c30e54e985d338134dfb3823f004 (diff) |
Test QLocale's parsing of small fractions with big exponents
Add some tests inspired by the initial form of a bug report (before we
found out what the real issue was), that a small fraction with a large
exponent is correctly handled. This should work as long as the result
is representable, even if the fraction itself is too small to be
represented by the floating-point type.
Pick-to: 6.5
Task-number: QTBUG-113443
Change-Id: Ie004197961fc7b603e5024a6ebc5928261a0e2bb
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/corelib/text/qlocale')
-rw-r--r-- | tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index 762b1ed6c4..579a2fd8f7 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -944,6 +944,13 @@ void tst_QLocale::stringToDouble_data() // Underflow: QTest::newRow("C tiny") << QString("C") << QString("2e-324") << false << 0.; QTest::newRow("C -tiny") << QString("C") << QString("-2e-324") << false << 0.; + + // Test a tiny fraction (well beyond denomal) with a huge exponent: + const QString zeros(500, '0'); + QTest::newRow("C tiny fraction, huge exponent") + << u"C"_s << u"0."_s + zeros + u"123e501"_s << true << 1.23; + QTest::newRow("uk_UA tiny fraction, huge exponent") + << u"uk_UA"_s << u"0,"_s + zeros + u"123\u0415" "501"_s << true << 1.23; } void tst_QLocale::stringToDouble() @@ -1030,6 +1037,13 @@ void tst_QLocale::stringToFloat_data() // Underflow double, too: QTest::newRow("C tiny") << C << QString("2e-324") << false << 0.; QTest::newRow("C -tiny") << C << QString("-2e-324") << false << 0.; + + // Test a small fraction (well beyond denomal) with a big exponent: + const QString zeros(80, '0'); + QTest::newRow("C small fraction, big exponent") + << u"C"_s << u"0."_s + zeros + u"123e81"_s << true << 1.23; + QTest::newRow("uk_UA small fraction, big exponent") + << u"uk_UA"_s << u"0,"_s + zeros + u"123\u0415" "81"_s << true << 1.23; } void tst_QLocale::stringToFloat() |