aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-06-28 10:39:51 +0200
committerLiang Qi <liang.qi@qt.io>2018-06-28 10:34:21 +0000
commitffeaac704efc9eb85464d0a401d98e28991ec4d3 (patch)
tree71d1086b1287153a4d1e77500f940155fccf95a7 /tests
parentd6177808d6bff7f8d950bb3110daba9011e1c461 (diff)
Adapt floating point precision test to changes in QtBase
After commit 91f3687ee51db83d9018bd61c3fbc736c6e9912e in qtbase, QString::number defaults to zero-padding the exponent. This change allows both variants to pass the test. After the next qt5 update we can remove the alternation. Change-Id: Ica6cfd49a7ab0ab5aab4c3ec204de7fe9e3afb93 Task-number: QTBUG-69181 Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 1e9ba80264..68ba879ce9 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -2064,40 +2064,48 @@ void tst_qqmlproperty::floatToStringPrecision_data()
QTest::addColumn<QString>("propertyName");
QTest::addColumn<double>("number");
QTest::addColumn<QString>("qtString");
+ QTest::addColumn<QString>("alternateQtString");
QTest::addColumn<QString>("jsString");
- QTest::newRow("3.4") << "a" << 3.4 << "3.4" << "3.4";
- QTest::newRow("0.035003945") << "b" << 0.035003945 << "0.035003945" << "0.035003945";
- QTest::newRow("0.0000012345") << "c" << 0.0000012345 << "1.2345e-6" << "0.0000012345";
- QTest::newRow("0.00000012345") << "d" << 0.00000012345 << "1.2345e-7" << "1.2345e-7";
- QTest::newRow("1e20") << "e" << 1e20 << "1e+20" << "100000000000000000000";
- QTest::newRow("1e21") << "f" << 1e21 << "1e+21" << "1e+21";
+ QTest::newRow("3.4") << "a" << 3.4 << "3.4" << "3.4" << "3.4";
+ QTest::newRow("0.035003945") << "b" << 0.035003945 << "0.035003945" << "0.0035003945" << "0.035003945";
+ QTest::newRow("0.0000012345") << "c" << 0.0000012345 << "1.2345e-6" << "1.2345e-06" << "0.0000012345";
+ QTest::newRow("0.00000012345") << "d" << 0.00000012345 << "1.2345e-7" << "1.2345e-07" << "1.2345e-7";
+ QTest::newRow("1e20") << "e" << 1e20 << "1e+20" << "1e+20" << "100000000000000000000";
+ QTest::newRow("1e21") << "f" << 1e21 << "1e+21" << "1e+21" << "1e+21";
}
void tst_qqmlproperty::floatToStringPrecision()
{
QQmlComponent comp(&engine, testFileUrl("floatToStringPrecision.qml"));
- QObject *obj = comp.create();
+ QScopedPointer<QObject> obj(comp.create());
QVERIFY(obj != nullptr);
QFETCH(QString, propertyName);
QFETCH(double, number);
QFETCH(QString, qtString);
+ QFETCH(QString, alternateQtString);
QFETCH(QString, jsString);
QByteArray name = propertyName.toLatin1();
QCOMPARE(obj->property(name).toDouble(), number);
- QCOMPARE(obj->property(name).toString(), qtString);
+ if (obj->property(name).toString() != qtString) {
+ QCOMPARE(obj->property(name).toString(), alternateQtString);
+ } else {
+ QCOMPARE(obj->property(name).toString(), qtString);
+ }
QByteArray name1 = (propertyName + QLatin1Char('1')).toLatin1();
QCOMPARE(obj->property(name1).toDouble(), number);
- QCOMPARE(obj->property(name1).toString(), qtString);
+ if (obj->property(name1).toString() != qtString) {
+ QCOMPARE(obj->property(name1).toString(), alternateQtString);
+ } else {
+ QCOMPARE(obj->property(name1).toString(), qtString);
+ }
QByteArray name2 = (propertyName + QLatin1Char('2')).toLatin1();
QCOMPARE(obj->property(name2).toDouble(), number);
QCOMPARE(obj->property(name2).toString(), jsString);
-
- delete obj;
}
void tst_qqmlproperty::initTestCase()