summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-04-11 15:19:26 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-04-11 19:53:32 +0200
commit65e3dc5eac4b790b69e76ad5d2ba5fb5a64b066e (patch)
tree9b89f50688ff470dfb397df42b6f2215d66a5f22 /tests/auto/gui
parent7266bd459e7cf8d4f4e3ad67b4ff23dea4fbfd0e (diff)
Fix warnings about lossy double/float conversion in tests
QVectorND, QQuaternion, and QColor all operate on floats rather than qreal or double, so explicit use float literals in the tests. Pick-to: 6.1 Change-Id: If12cc12ddd9cd8219f3d78bf24e1400921e26c2b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp2
-rw-r--r--tests/auto/gui/painting/qcolor/tst_qcolor.cpp94
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp10
-rw-r--r--tests/auto/gui/text/qcssparser/tst_qcssparser.cpp4
4 files changed, 55 insertions, 55 deletions
diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
index b9ba7278da..aaf0fb7e0d 100644
--- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
@@ -905,7 +905,7 @@ void tst_QQuaternion::fromAxes_data()
QTest::newRow("complex")
<< 1.0f << 2.0f << -3.0f << 45.0f
- << QVector3D(0.728028, -0.525105, -0.440727) << QVector3D(0.608789, 0.790791, 0.0634566) << QVector3D(0.315202, -0.314508, 0.895395);
+ << QVector3D(0.728028f, -0.525105f, -0.440727f) << QVector3D(0.608789f, 0.790791f, 0.0634566f) << QVector3D(0.315202f, -0.314508f, 0.895395f);
}
void tst_QQuaternion::fromAxes()
{
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
index a5a2983ce7..03cece5135 100644
--- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
+++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp
@@ -139,11 +139,11 @@ void tst_QColor::getSetCheck()
// void QColor::setAlphaF(float)
obj1.setAlphaF(0.0);
QCOMPARE(obj1.alphaF(), 0.0f); // range<0.0, 1.0>
- obj1.setAlphaF(-0.2);
+ obj1.setAlphaF(-0.2f);
QCOMPARE(obj1.alphaF(), 0.0f); // range<0.0, 1.0>
- obj1.setAlphaF(1.0);
+ obj1.setAlphaF(1.0f);
QCOMPARE(obj1.alphaF(), 1.0f); // range<0.0, 1.0>
- obj1.setAlphaF(1.1);
+ obj1.setAlphaF(1.1f);
QCOMPARE(obj1.alphaF(), 1.0f); // range<0.0, 1.0>
// int QColor::red()
@@ -1421,58 +1421,58 @@ void tst_QColor::toRgb_data()
QTest::addColumn<QColor>("hslColor");
QTest::newRow("black")
- << QColor::fromRgbF(0.0, 0.0, 0.0)
- << QColor::fromHsvF(-1.0, 0.0, 0.0)
- << QColor::fromCmykF(0.0, 0.0, 0.0, 1.0)
- << QColor::fromHslF(-1.0, 0.0, 0.0);
+ << QColor::fromRgbF(0.0f, 0.0f, 0.0f)
+ << QColor::fromHsvF(-1.0f, 0.0f, 0.0f)
+ << QColor::fromCmykF(0.0f, 0.0f, 0.0f, 1.0f)
+ << QColor::fromHslF(-1.0f, 0.0f, 0.0f);
QTest::newRow("white")
- << QColor::fromRgbF(1.0, 1.0, 1.0)
- << QColor::fromHsvF(-1.0, 0.0, 1.0)
- << QColor::fromCmykF(0.0, 0.0, 0.0, 0.0)
- << QColor::fromHslF(-1.0, 0.0, 1.0);
+ << QColor::fromRgbF(1.0f, 1.0f, 1.0f)
+ << QColor::fromHsvF(-1.0f, 0.0f, 1.0f)
+ << QColor::fromCmykF(0.0f, 0.0f, 0.0f, 0.0f)
+ << QColor::fromHslF(-1.0f, 0.0f, 1.0f);
QTest::newRow("red")
- << QColor::fromRgbF(1.0, 0.0, 0.0)
- << QColor::fromHsvF(0.0, 1.0, 1.0)
- << QColor::fromCmykF(0.0, 1.0, 1.0, 0.0)
- << QColor::fromHslF(0.0, 1.0, 0.5, 1.0);
+ << QColor::fromRgbF(1.0f, 0.0f, 0.0f)
+ << QColor::fromHsvF(0.0f, 1.0f, 1.0f)
+ << QColor::fromCmykF(0.0f, 1.0f, 1.0f, 0.0f)
+ << QColor::fromHslF(0.0f, 1.0f, 0.5f, 1.0f);
QTest::newRow("green")
- << QColor::fromRgbF(0.0, 1.0, 0.0)
- << QColor::fromHsvF(0.33333, 1.0, 1.0)
- << QColor::fromCmykF(1.0, 0.0, 1.0, 0.0)
- << QColor::fromHslF(0.33333, 1.0, 0.5);
+ << QColor::fromRgbF(0.0f, 1.0f, 0.0f)
+ << QColor::fromHsvF(0.33333f, 1.0f, 1.0f)
+ << QColor::fromCmykF(1.0, 0.0f, 1.0f, 0.0f)
+ << QColor::fromHslF(0.33333f, 1.0f, 0.5f);
QTest::newRow("blue")
- << QColor::fromRgbF(0.0, 0.0, 1.0)
- << QColor::fromHsvF(0.66667, 1.0, 1.0)
- << QColor::fromCmykF(1.0, 1.0, 0.0, 0.0)
- << QColor::fromHslF(0.66667, 1.0, 0.5);
+ << QColor::fromRgbF(0.0f, 0.0f, 1.0f)
+ << QColor::fromHsvF(0.66667f, 1.0f, 1.0f)
+ << QColor::fromCmykF(1.0f, 1.0f, 0.0f, 0.0f)
+ << QColor::fromHslF(0.66667f, 1.0f, 0.5f);
QTest::newRow("cyan")
- << QColor::fromRgbF(0.0, 1.0, 1.0)
- << QColor::fromHsvF(0.5, 1.0, 1.0)
- << QColor::fromCmykF(1.0, 0.0, 0.0, 0.0)
- << QColor::fromHslF(0.5, 1.0, 0.5);
+ << QColor::fromRgbF(0.0f, 1.0f, 1.0f)
+ << QColor::fromHsvF(0.5f, 1.0f, 1.0f)
+ << QColor::fromCmykF(1.0f, 0.0f, 0.0f, 0.0f)
+ << QColor::fromHslF(0.5f, 1.0f, 0.5f);
QTest::newRow("magenta")
- << QColor::fromRgbF(1.0, 0.0, 1.0)
- << QColor::fromHsvF(0.83333, 1.0, 1.0)
- << QColor::fromCmykF(0.0, 1.0, 0.0, 0.0)
- << QColor::fromHslF(0.83333, 1.0, 0.5);
+ << QColor::fromRgbF(1.0f, 0.0f, 1.0f)
+ << QColor::fromHsvF(0.83333f, 1.0f, 1.0f)
+ << QColor::fromCmykF(0.0f, 1.0f, 0.0f, 0.0f)
+ << QColor::fromHslF(0.83333f, 1.0f, 0.5f);
QTest::newRow("yellow")
- << QColor::fromRgbF(1.0, 1.0, 0.0)
- << QColor::fromHsvF(0.16667, 1.0, 1.0)
- << QColor::fromCmykF(0.0, 0.0, 1.0, 0.0)
- << QColor::fromHslF(0.16667, 1.0, 0.5);
+ << QColor::fromRgbF(1.0f, 1.0f, 0.0f)
+ << QColor::fromHsvF(0.16667f, 1.0f, 1.0f)
+ << QColor::fromCmykF(0.0f, 0.0f, 1.0f, 0.0f)
+ << QColor::fromHslF(0.16667f, 1.0f, 0.5f);
QTest::newRow("gray")
- << QColor::fromRgbF(0.6431375, 0.6431375, 0.6431375)
- << QColor::fromHsvF(-1.0, 0.0, 0.6431375)
- << QColor::fromCmykF(0.0, 0.0, 0.0, 0.356863)
- << QColor::fromHslF(-1.0, 0.0, 0.6431375);
+ << QColor::fromRgbF(0.6431375f, 0.6431375f, 0.6431375f)
+ << QColor::fromHsvF(-1.0f, 0.0f, 0.6431375f)
+ << QColor::fromCmykF(0.0f, 0.0f, 0.0f, 0.356863f)
+ << QColor::fromHslF(-1.0f, 0.0f, 0.6431375f);
// ### add colors using the 0-255 functions
}
@@ -1503,7 +1503,7 @@ void tst_QColor::toHsv_data()
<< QColor::fromHsv(300, 255, 255)
<< QColor(255, 0, 255)
<< QColor::fromCmyk(0, 255, 0, 0)
- << QColor::fromHslF(300./360., 1., 0.5, 1.0);
+ << QColor::fromHslF(300.f/360.f, 1.f, 0.5f, 1.0f);
QTest::newRow("data1")
<< QColor::fromHsvF(1., 1., 1., 1.)
@@ -1514,7 +1514,7 @@ void tst_QColor::toHsv_data()
void tst_QColor::toRgbNonDestructive()
{
- QColor aColor = QColor::fromRgbF(0.11, 0.22, 0.33, 0.44);
+ QColor aColor = QColor::fromRgbF(0.11f, 0.22f, 0.33f, 0.44f);
QCOMPARE(aColor, aColor.toRgb());
}
@@ -1534,7 +1534,7 @@ void tst_QColor::toHsv()
void tst_QColor::toHsvNonDestructive()
{
- QColor aColor = QColor::fromHsvF(0.11, 0.22, 0.33, 0.44);
+ QColor aColor = QColor::fromHsvF(0.11f, 0.22f, 0.33f, 0.44f);
QCOMPARE(aColor, aColor.toHsv());
}
@@ -1546,7 +1546,7 @@ void tst_QColor::toCmyk_data()
QTest::addColumn<QColor>("hslColor");
QTest::newRow("data0")
- << QColor::fromCmykF(1.0, 0.0, 0.0, 0.0)
+ << QColor::fromCmykF(1.0f, 0.0f, 0.0f, 0.0f)
<< QColor(0, 255, 255)
<< QColor::fromHsv(180, 255, 255)
<< QColor::fromHslF(180./360., 1., 0.5, 1.0);
@@ -1574,7 +1574,7 @@ void tst_QColor::toCmyk()
void tst_QColor::toCmykNonDestructive()
{
- QColor aColor = QColor::fromCmykF(0.11, 0.22, 0.33, 0.44);
+ QColor aColor = QColor::fromCmykF(0.11f, 0.22f, 0.33f, 0.44f);
QCOMPARE(aColor, aColor.toCmyk());
}
@@ -1587,13 +1587,13 @@ void tst_QColor::toHsl_data()
QTest::newRow("data0")
- << QColor::fromHslF(300./360., 1., 0.5, 1.0)
+ << QColor::fromHslF(300.f/360.f, 1., 0.5f, 1.0)
<< QColor::fromHsv(300, 255, 255)
<< QColor(255, 0, 255)
<< QColor::fromCmyk(0, 255, 0, 0);
QTest::newRow("data1")
- << QColor::fromHslF(1., 1., 0.5, 1.0)
+ << QColor::fromHslF(1., 1., 0.5f, 1.0)
<< QColor::fromHsvF(1., 1., 1., 1.)
<< QColor(255, 0, 0, 255)
<< QColor::fromCmykF(0., 1., 1., 0.);
@@ -1618,7 +1618,7 @@ void tst_QColor::toHsl()
void tst_QColor::toHslNonDestructive()
{
- QColor aColor = QColor::fromHslF(0.11, 0.22, 0.33, 0.44);
+ QColor aColor = QColor::fromHslF(0.11f, 0.22f, 0.33f, 0.44f);
QCOMPARE(aColor, aColor.toHsl());
}
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index ce21dbe9b7..0c8536d385 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -449,11 +449,11 @@ void tst_QColorSpace::loadImage()
void tst_QColorSpace::primaries()
{
- QColor black = QColor::fromRgbF(0.0, 0.0, 0.0);
- QColor white = QColor::fromRgbF(1.0, 1.0, 1.0);
- QColor red = QColor::fromRgbF(1.0, 0.0, 0.0);
- QColor green = QColor::fromRgbF(0.0, 1.0, 0.0);
- QColor blue = QColor::fromRgbF(0.0, 0.0, 1.0);
+ QColor black = QColor::fromRgbF(0.0f, 0.0f, 0.0f);
+ QColor white = QColor::fromRgbF(1.0f, 1.0f, 1.0f);
+ QColor red = QColor::fromRgbF(1.0f, 0.0f, 0.0f);
+ QColor green = QColor::fromRgbF(0.0f, 1.0f, 0.0f);
+ QColor blue = QColor::fromRgbF(0.0f, 0.0f, 1.0f);
QColorTransform toAdobeRgb = QColorSpace(QColorSpace::SRgb).transformationToColorSpace(QColorSpace::AdobeRgb);
diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
index ef86d06cb4..0af87353b6 100644
--- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
+++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp
@@ -844,11 +844,11 @@ void tst_QCssParser::colorValue_data()
QTest::newRow("hsva") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40);
// the percent and float values are well chosen to not get in trouble due to rounding errors
QTest::newRow("hsva-percent") << "color: hsva(100%, 20%, 40%, 60%)" << QColor::fromHsv(359, 51, 102, 153);
- QTest::newRow("hsva-float") << "color: hsva(180, 20%, 40%, 0.6)" << QColor::fromHsvF(0.5, 0.2, 0.4, 0.6);
+ QTest::newRow("hsva-float") << "color: hsva(180, 20%, 40%, 0.6)" << QColor::fromHsvF(0.5f, 0.2f, 0.4f, 0.6f);
QTest::newRow("hsl") << "color: hsl(60, 100%, 50%)" << QColor::fromHsl(60., 255, 127);
QTest::newRow("hsla") << "color: hsla(240, 255, 127, 192)" << QColor::fromHsl(240, 255, 127, 192);
QTest::newRow("hsla-percent") << "color: hsla(100%, 80%, 40%, 0%)" << QColor::fromHsl(359, 204, 102, 0);
- QTest::newRow("hsla-float") << "color: hsla(252, 40%, 60%, 0.2)" << QColor::fromHslF(0.7, 0.4, 0.6, 0.2);
+ QTest::newRow("hsla-float") << "color: hsla(252, 40%, 60%, 0.2)" << QColor::fromHslF(0.7f, 0.4f, 0.6f, 0.2f);
QTest::newRow("invalid1") << "color: rgb(why, does, it, always, rain, on, me)" << QColor();
QTest::newRow("invalid2") << "color: rgba(i, meant, norway)" << QColor();
QTest::newRow("invalid3") << "color: rgb(21)" << QColor();