From 59dbf1786f22ec4ac88d8f9d38cac5cfb82acaea Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 4 Nov 2015 12:01:08 +0100 Subject: QLocale: Return overflowing numbers from asciiToDouble() The behavior from before libdouble-conversion is that in case of an overflow the OK flag is set to false, but the returned number is still infinity, rather than 0. Also, the number of processed characters is always set to the number of characters actually processed, unless garbage is found. There is an important distinction between an overflow and garbage. The client code may accept overflows and infinity may be a valid result. Garbage is most certainly not acceptable. Having an infinity/false result in addition to 0/false allows the client code to distinguish those. One application where this is useful is parsing JavaScript. Change-Id: I4b8581568144b44fca3353c4bd9685c702762af9 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index d765a80042..2da7a83568 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1931,13 +1931,13 @@ a(QLatin1String("0.0000000000000000000000000000000000000000000000000000000000000 ok = false; d = a.toDouble(&ok); QVERIFY(!ok); // detectable overflow - QCOMPARE(d, 0.0); + QVERIFY(qIsInf(d)); a = QLatin1String("-1e600"); ok = false; d = a.toDouble(&ok); QVERIFY(!ok); // detectable underflow - QCOMPARE(d, 0.0); + QVERIFY(qIsInf(-d)); a = QLatin1String("1e-600"); ok = false; -- cgit v1.2.3