summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2020-11-19 09:55:34 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2020-11-20 14:31:49 +0100
commit289f909621a8d83320d33e3ff7d651c164034098 (patch)
treed7b630c3d84758da80f7e634e372d5da13e88609 /tests/auto
parent5861e06568c44c58aecacdf26fd7938240348956 (diff)
Test conversion of ulonglong variant to JSON
Make sure ulonglong variant converts to a double JSON value when the value is greater than 2^63. Change-Id: I4d4392b05de29c220624056d5d0d4664fb2c08b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/serialization/json/tst_qtjson.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp
index 04411cea63..2153c9eff7 100644
--- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp
@@ -35,6 +35,7 @@ QT_WARNING_DISABLE_DEPRECATED
#include "qjsonvalue.h"
#include "qjsondocument.h"
#include "qregularexpression.h"
+#include "private/qnumeric_p.h"
#include <limits>
#define INVALID_UNICODE "\xCE\xBA\xE1"
@@ -3419,6 +3420,17 @@ void tst_QtJson::fromToVariantConversions_data()
<< QVariant::fromValue(nullptr);
QTest::newRow("NaN") << QVariant(qQNaN()) << QJsonValue(QJsonValue::Null)
<< QVariant::fromValue(nullptr);
+
+ const qulonglong ulongValue = (1ul << 63) + 1;
+ const double uLongToDouble = ulongValue;
+ qint64 n;
+ if (convertDoubleTo(uLongToDouble, &n)) {
+ QTest::newRow("ulonglong") << QVariant(ulongValue) << QJsonValue(uLongToDouble)
+ << QVariant(n);
+ } else {
+ QTest::newRow("ulonglong") << QVariant(ulongValue) << QJsonValue(uLongToDouble)
+ << QVariant(uLongToDouble);
+ }
}
void tst_QtJson::fromToVariantConversions()