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>
bb10
Edward Welbourne 2023-05-09 13:11:01 +02:00
parent 36e59db1bb
commit 74b377313e
1 changed files with 14 additions and 0 deletions

View File

@ -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()