summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/json
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-03-27 10:42:08 +0200
committerLiang Qi <liang.qi@qt.io>2017-03-27 10:42:08 +0200
commit7702fe86029c771e641a918baa221b9737c0f18e (patch)
tree8e0795bc4c701518e1c66922f8e8b0cb359da155 /tests/auto/corelib/json
parent1dd54b5647d33416c39fb41fdab560c815356951 (diff)
parent38550c562d918e783bb609622bc8fb46de1bfec4 (diff)
Merge remote-tracking branch 'origin/5.8' into 5.9
Diffstat (limited to 'tests/auto/corelib/json')
-rw-r--r--tests/auto/corelib/json/tst_qtjson.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp
index 6aa5165e24..b215364f0e 100644
--- a/tests/auto/corelib/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/json/tst_qtjson.cpp
@@ -32,6 +32,7 @@
#include "qjsonobject.h"
#include "qjsonvalue.h"
#include "qjsondocument.h"
+#include "qregularexpression.h"
#include <limits>
#define INVALID_UNICODE "\xCE\xBA\xE1"
@@ -49,6 +50,7 @@ private Q_SLOTS:
void testNumbers();
void testNumbers_2();
void testNumbers_3();
+ void testNumbers_4();
void testObjectSimple();
void testObjectSmallKeys();
@@ -375,6 +377,33 @@ void tst_QtJson::testNumbers_3()
QVERIFY(d1_1 != d2_1);
}
+void tst_QtJson::testNumbers_4()
+{
+ // no exponent notation used to print numbers between -2^64 and 2^64
+ QJsonArray array;
+ array << QJsonValue(+1000000000000000.0);
+ array << QJsonValue(-1000000000000000.0);
+ array << QJsonValue(+9007199254740992.0);
+ array << QJsonValue(-9007199254740992.0);
+ array << QJsonValue(+9223372036854775808.0);
+ array << QJsonValue(-9223372036854775808.0);
+ array << QJsonValue(+18446744073709551616.0);
+ array << QJsonValue(-18446744073709551616.0);
+ const QByteArray json(QJsonDocument(array).toJson());
+ const QByteArray expected =
+ "[\n"
+ " 1000000000000000,\n"
+ " -1000000000000000,\n"
+ " 9007199254740992,\n"
+ " -9007199254740992,\n"
+ " 9223372036854776000,\n"
+ " -9223372036854776000,\n"
+ " 18446744073709552000,\n"
+ " -18446744073709552000\n"
+ "]\n";
+ QCOMPARE(json, expected);
+}
+
void tst_QtJson::testObjectSimple()
{
QJsonObject object;