1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Description: adapt to JSON parser behavior change in Qt 5.15
QJsonValue will expose input like "2.0" as an integral type as
the value can be perfectly expressed as an integral.
.
See the discussion in https://bugreports.qt.io/browse/QTBUG-87443.
Origin: https://codereview.qt-project.org/c/qt/qtpim/+/317682
Last-Update: 2020-10-31
--- a/tests/auto/versit/qversitcontactimporter/tst_qversitcontactimporter.cpp
+++ b/tests/auto/versit/qversitcontactimporter/tst_qversitcontactimporter.cpp
@@ -1489,20 +1489,33 @@ void tst_QVersitContactImporter::testExt
}
{
- QTest::newRow("double data")
+ QTest::newRow("integral data")
<< QString("name")
- << QVariant((double)2.0)
+ << QVariant((qlonglong)2)
<< jsonArrayWith.arg("2")
<< true;
+ QTest::newRow("integral data - perfectly representable") // QTBUG-87443
+ << QString("name")
+ << QVariant((qlonglong)2)
+ << jsonArrayWith.arg("2.0")
+ << true;
+ }
+
+ {
+ QTest::newRow("double data")
+ << QString("name")
+ << QVariant((double)2.1)
+ << jsonArrayWith.arg("2.1")
+ << true;
QTest::newRow("double data, negative")
<< QString("name")
- << QVariant((double)-1.0)
- << jsonArrayWith.arg("-1")
+ << QVariant((double)-1.2)
+ << jsonArrayWith.arg("-1.2")
<< true;
QTest::newRow("double data, multiple digits")
<< QString("name")
- << QVariant((double)10.2)
- << jsonArrayWith.arg("10.2")
+ << QVariant((double)10.23456)
+ << jsonArrayWith.arg("10.23456")
<< true;
}
|