aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-04-11 15:21:41 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-12 11:38:18 +0000
commitf783ab6049774888308e24bf6e4218a7035a4d12 (patch)
tree70328085ea8995193ae7cc15a52e29624e82bf78 /tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
parentce452b70e158461b021aa47faf5cce87964b6cf7 (diff)
Fix warnings about lossy double/float conversion in tests
QColor operates on floats, not qreal or double, so explicitly use float literals in test code. Change-Id: I6f0cb56e861b4812fc79ce67ade9abe3ee9dfddc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io> (cherry picked from commit 8bb955e22f027fc3fd9402383445685cb4185744) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/qml/qqmlqt/tst_qqmlqt.cpp')
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
index 9406ba5d6a..e4f28c29fb 100644
--- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -189,8 +189,8 @@ void tst_qqmlqt::rgba()
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8f));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5f, 0.3f, 1));
QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1));
@@ -209,8 +209,8 @@ void tst_qqmlqt::hsla()
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8f));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5f, 0.3f, 1));
QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHslF(1, 1, 1, 1));
@@ -229,8 +229,8 @@ void tst_qqmlqt::hsva()
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHsvF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHsvF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHsvF(1, 0, 0, 0.8f));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHsvF(1, 0.5f, 0.3f, 1));
QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHsvF(1, 1, 1, 1));
@@ -503,13 +503,13 @@ void tst_qqmlqt::lighter()
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8f, 0.3f).lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("testColor1")),
- QColor::fromRgbF(1, 0.8, 0.3).lighter());
+ QColor::fromRgbF(1, 0.8f, 0.3f).lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8f, 0.3f).lighter(180));
QCOMPARE(qvariant_cast<QColor>(object->property("testColor3")),
- QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
+ QColor::fromRgbF(1, 0.8f, 0.3f).lighter(180));
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("testColor4")), QColor("red").lighter());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
@@ -528,13 +528,13 @@ void tst_qqmlqt::darker()
QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8f, 0.3f).darker());
QCOMPARE(qvariant_cast<QColor>(object->property("testColor1")),
- QColor::fromRgbF(1, 0.8, 0.3).darker());
+ QColor::fromRgbF(1, 0.8f, 0.3f).darker());
QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8f, 0.3f).darker(280));
QCOMPARE(qvariant_cast<QColor>(object->property("testColor3")),
- QColor::fromRgbF(1, 0.8, 0.3).darker(280));
+ QColor::fromRgbF(1, 0.8f, 0.3f).darker(280));
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
QCOMPARE(qvariant_cast<QColor>(object->property("testColor4")), QColor("red").darker());
QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
@@ -554,17 +554,17 @@ void tst_qqmlqt::alpha()
QVERIFY(object != nullptr);
QCOMPARE(qvariant_cast<QColor>(object->property("test1")),
- QColor::fromRgbF(1.0, 0.8, 0.3, 0.5));
+ QColor::fromRgbF(1.0f, 0.8f, 0.3f, 0.5f));
QCOMPARE(qvariant_cast<QColor>(object->property("testColor1")),
- QColor::fromRgbF(1, 0.8, 0.3, 0.5));
+ QColor::fromRgbF(1, 0.8f, 0.3f, 0.5));
QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
QCOMPARE(qvariant_cast<QColor>(object->property("test3")),
- QColor::fromRgbF(1.0, 0.8, 0.3, 0.7));
+ QColor::fromRgbF(1.0f, 0.8f, 0.3f, 0.7f));
QCOMPARE(qvariant_cast<QColor>(object->property("testColor3")),
- QColor::fromRgbF(1, 0.8, 0.3, 0.7));
+ QColor::fromRgbF(1, 0.8f, 0.3f, 0.7f));
QColor alphaRed = QColor("red");
- alphaRed.setAlphaF(0.5);
+ alphaRed.setAlphaF(0.5f);
QCOMPARE(qvariant_cast<QColor>(object->property("test4")), alphaRed);
QCOMPARE(qvariant_cast<QColor>(object->property("testColor4")), alphaRed);