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. 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> (cherry picked from commit 74b377313e98e0fa745e21524e220c9619dd8bb2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9e7f1f3e57
commit
fdbddb179b
@ -903,6 +903,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()
|
||||
@ -990,6 +997,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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user