summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-09-10 12:36:54 +0200
committerQt by Nokia <qt-info@nokia.com>2012-09-11 09:25:24 +0200
commitfa6497d7ee448a8d63a52279254a7b8e84bf39dc (patch)
tree8e021d086faf0804c5a9486a97bfde38254672b6 /tests/auto
parent2aea59ec705d8f83e40a82f3740d4d586d88fb8e (diff)
Compile after Math3d was changed to use float instead of qreal.
Introduced by qtbase: 51d40d7e9bdfc63c5109aef5b732aa2ba10f985a . Fix warnings about truncation from double to float. Introduce qFuzzyCompare() and mark some tests as insignificant. Task-number: QTBUG-27189 Change-Id: Icc2038df5c4c25a7fa9a89ed906a934c2af60cec Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp150
-rw-r--r--tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp6
-rw-r--r--tests/auto/threed/qglmaterial/tst_qglmaterial.cpp6
-rw-r--r--tests/auto/threed/qglpainter/tst_qglpainter.cpp2
-rw-r--r--tests/auto/threed/qglscenenode/tst_qglscenenode.cpp6
-rw-r--r--tests/auto/threed/qglsection/qglsection.pro1
-rw-r--r--tests/auto/threed/qglsection/tst_qglsection.cpp2
-rw-r--r--tests/auto/threed/qray3d/qray3d.pro1
-rw-r--r--tests/auto/threed/qray3d/tst_qray3d.cpp2
-rw-r--r--tests/auto/threed/qsphere3d/tst_qsphere3d.cpp2
-rw-r--r--tests/auto/threed/qtriangle3d/qtriangle3d.pro1
11 files changed, 91 insertions, 88 deletions
diff --git a/tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp b/tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp
index 382817539..781c86aa6 100644
--- a/tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp
+++ b/tests/auto/threed/qgeometrydata/tst_qgeometrydata.cpp
@@ -99,10 +99,10 @@ void tst_QGeometryData::createDefault()
void tst_QGeometryData::appendVertex()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
{
QGeometryData data;
data.appendVertex(a);
@@ -217,14 +217,14 @@ void tst_QGeometryData::appendNormal()
void tst_QGeometryData::appendVertexNormal()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
- QVector3D an(5.1, 5.2, 5.3);
- QVector3D bn(6.1, 6.2, 6.3);
- QVector3D cn(7.1, 7.2, 7.3);
- QVector3D dn(8.1, 8.2, 8.3);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
+ QVector3D an(5.1f, 5.2f, 5.3f);
+ QVector3D bn(6.1f, 6.2f, 6.3f);
+ QVector3D cn(7.1f, 7.2f, 7.3f);
+ QVector3D dn(8.1f, 8.2f, 8.3f);
{
QGeometryData data;
data.appendVertex(a);
@@ -303,7 +303,7 @@ void tst_QGeometryData::appendVertexNormal()
}
-QVector3D avec(99.1, 99.2, 99.3);
+QVector3D avec(99.1f, 99.2f, 99.3f);
static QGeometryData aFunc(const QGeometryData& g) // not a copy but a ref
{
@@ -314,10 +314,10 @@ static QGeometryData aFunc(const QGeometryData& g) // not a copy but a ref
void tst_QGeometryData::copy()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
{
QGeometryData data;
QCOMPARE(data.count(), 0);
@@ -352,16 +352,16 @@ void tst_QGeometryData::copy()
void tst_QGeometryData::interleaveWith()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
- QVector3D vx(0.7071, 0.7071, 0.0);
- QVector2D at(0.11, 0.12);
- QVector2D bt(0.21, 0.22);
- QVector2D ct(0.31, 0.32);
- QVector2D dt(0.41, 0.42);
- QVector2D tx(1.0, 1.0);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
+ QVector3D vx(0.7071f, 0.7071f, 0.0f);
+ QVector2D at(0.11f, 0.12f);
+ QVector2D bt(0.21f, 0.22f);
+ QVector2D ct(0.31f, 0.32f);
+ QVector2D dt(0.41f, 0.42f);
+ QVector2D tx(1.0f, 1.0f);
QGeometryData data;
data.appendVertex(a, b, c, d);
@@ -445,40 +445,40 @@ void tst_QGeometryData::center()
void tst_QGeometryData::normalizeNormals()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
- QVector3D an(5.1, 5.2, 5.3);
- QVector3D bn(6.1, 6.2, 6.3);
- QVector3D cn(7.1, 7.2, 7.3);
- QVector3D dn(8.1, 8.2, 8.3);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
+ QVector3D an(5.1f, 5.2f, 5.3f);
+ QVector3D bn(6.1f, 6.2f, 6.3f);
+ QVector3D cn(7.1f, 7.2f, 7.3f);
+ QVector3D dn(8.1f, 8.2f, 8.3f);
QGeometryData data;
data.appendVertex(a, b, c, d);
data.appendNormal(an, bn, cn, dn);
data.normalizeNormals();
- QVERIFY(qFskCompare(data.normalAt(0), QVector3D(0.566178, 0.577279, 0.588381)));
- QVERIFY(qFskCompare(data.normalAt(1), QVector3D(0.567989, 0.577300, 0.586612)));
- QVERIFY(qFskCompare(data.normalAt(2), QVector3D(0.569295, 0.577313, 0.585331)));
- QVERIFY(qFskCompare(data.normalAt(3), QVector3D(0.570281, 0.577322, 0.584362)));
- QVERIFY(qFskCompare(data.normalAt(0).lengthSquared(), qreal(1.0f)));
- QVERIFY(qFskCompare(data.normalAt(1).lengthSquared(), qreal(1.0f)));
- QVERIFY(qFskCompare(data.normalAt(2).lengthSquared(), qreal(1.0f)));
- QVERIFY(qFskCompare(data.normalAt(3).lengthSquared(), qreal(1.0f)));
+ QVERIFY(qFskCompare(data.normalAt(0), QVector3D(0.566178f, 0.577279f, 0.588381f)));
+ QVERIFY(qFskCompare(data.normalAt(1), QVector3D(0.567989f, 0.577300f, 0.586612f)));
+ QVERIFY(qFskCompare(data.normalAt(2), QVector3D(0.569295f, 0.577313f, 0.585331f)));
+ QVERIFY(qFskCompare(data.normalAt(3), QVector3D(0.570281f, 0.577322f, 0.584362f)));
+ QVERIFY(qFskCompare(data.normalAt(0).lengthSquared(), 1.0f));
+ QVERIFY(qFskCompare(data.normalAt(1).lengthSquared(), 1.0f));
+ QVERIFY(qFskCompare(data.normalAt(2).lengthSquared(), 1.0f));
+ QVERIFY(qFskCompare(data.normalAt(3).lengthSquared(), 1.0f));
}
void tst_QGeometryData::reversed()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
- QVector3D an(5.1, 5.2, 5.3);
- QVector3D bn(6.1, 6.2, 6.3);
- QVector3D cn(7.1, 7.2, 7.3);
- QVector3D dn(8.1, 8.2, 8.3);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
+ QVector3D an(5.1f, 5.2f, 5.3f);
+ QVector3D bn(6.1f, 6.2f, 6.3f);
+ QVector3D cn(7.1f, 7.2f, 7.3f);
+ QVector3D dn(8.1f, 8.2f, 8.3f);
QGeometryData data;
data.appendVertex(a, b, c, d);
@@ -498,14 +498,14 @@ void tst_QGeometryData::reversed()
void tst_QGeometryData::translated()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
- QVector3D an(5.1, 5.2, 5.3);
- QVector3D bn(6.1, 6.2, 6.3);
- QVector3D cn(7.1, 7.2, 7.3);
- QVector3D dn(8.1, 8.2, 8.3);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
+ QVector3D an(5.1f, 5.2f, 5.3f);
+ QVector3D bn(6.1f, 6.2f, 6.3f);
+ QVector3D cn(7.1f, 7.2f, 7.3f);
+ QVector3D dn(8.1f, 8.2f, 8.3f);
QGeometryData data;
data.appendVertex(a, b, c, d);
@@ -564,14 +564,14 @@ void tst_QGeometryData::generateTextureCoordinates()
void tst_QGeometryData::clear()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
- QVector3D an(5.1, 5.2, 5.3);
- QVector3D bn(6.1, 6.2, 6.3);
- QVector3D cn(7.1, 7.2, 7.3);
- QVector3D dn(8.1, 8.2, 8.3);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
+ QVector3D an(5.1f, 5.2f, 5.3f);
+ QVector3D bn(6.1f, 6.2f, 6.3f);
+ QVector3D cn(7.1f, 7.2f, 7.3f);
+ QVector3D dn(8.1f, 8.2f, 8.3f);
QGeometryData data;
data.appendVertex(a, b, c, d);
@@ -605,14 +605,14 @@ void tst_QGeometryData::clear()
void tst_QGeometryData::draw()
{
- QVector3D a(1.1, 1.2, 1.3);
- QVector3D b(2.1, 2.2, 2.3);
- QVector3D c(3.1, 3.2, 3.3);
- QVector3D d(4.1, 4.2, 4.3);
- QVector3D an(5.1, 5.2, 5.3);
- QVector3D bn(6.1, 6.2, 6.3);
- QVector3D cn(7.1, 7.2, 7.3);
- QVector3D dn(8.1, 8.2, 8.3);
+ QVector3D a(1.1f, 1.2f, 1.3f);
+ QVector3D b(2.1f, 2.2f, 2.3f);
+ QVector3D c(3.1f, 3.2f, 3.3f);
+ QVector3D d(4.1f, 4.2f, 4.3f);
+ QVector3D an(5.1f, 5.2f, 5.3f);
+ QVector3D bn(6.1f, 6.2f, 6.3f);
+ QVector3D cn(7.1f, 7.2f, 7.3f);
+ QVector3D dn(8.1f, 8.2f, 8.3f);
QGeometryData data;
data.appendVertex(a, b, c, d);
diff --git a/tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp b/tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp
index 913f735b2..3e297362e 100644
--- a/tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp
+++ b/tests/auto/threed/qgllightparameters/tst_qgllightparameters.cpp
@@ -263,11 +263,11 @@ void tst_QGLLightParameters::transform()
m.rotate(45.0f, 1.0f, 1.0f, 1.0f);
m.scale(2.0f);
- QCOMPARE(params.eyePosition(m), m * QVector4D(1, 2, -3, 1));
- QCOMPARE(params.eyeSpotDirection(m), m.mapVector(QVector3D(-5, 1, 3)));
+ QVERIFY(qFuzzyCompare(params.eyePosition(m), m * QVector4D(1, 2, -3, 1)));
+ QVERIFY(qFuzzyCompare(params.eyeSpotDirection(m), m.mapVector(QVector3D(-5, 1, 3))));
params.setDirection(QVector3D(-1, -2, 3));
- QCOMPARE(params.eyePosition(m), m * QVector4D(-1, -2, 3, 0));
+ QVERIFY(qFuzzyCompare(params.eyePosition(m), m * QVector4D(-1, -2, 3, 0)));
}
QTEST_APPLESS_MAIN(tst_QGLLightParameters)
diff --git a/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp b/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp
index b4cd4a819..e13767b6d 100644
--- a/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp
+++ b/tests/auto/threed/qglmaterial/tst_qglmaterial.cpp
@@ -659,7 +659,7 @@ static QColor litColor(const QGLMaterial &material)
else
toLight = (pli.toVector3D() - vertex).normalized();
- qreal angle = qMax(QVector3D::dotProduct(normal, toLight), qreal(0.0f));
+ float angle = qMax(QVector3D::dotProduct(normal, toLight), 0.0f);
QVector4D adcomponent = colorToVector4D(material.ambientColor()) *
colorToVector4D(light.ambientColor());
@@ -669,7 +669,7 @@ static QColor litColor(const QGLMaterial &material)
QVector4D scomponent;
if (angle != 0.0f) {
QVector3D h = (toLight + toEye).normalized();
- angle = qMax(QVector3D::dotProduct(normal, h), qreal(0.0f));
+ angle = qMax(QVector3D::dotProduct(normal, h), 0.0f);
if (material.shininess() != 0.0f) {
scomponent = qPow(angle, material.shininess()) *
colorToVector4D(material.specularColor()) *
@@ -684,7 +684,7 @@ static QColor litColor(const QGLMaterial &material)
if (light.spotAngle() != 180.0f) {
qreal spot = qMax(QVector3D::dotProduct
- (vertex - pli.toVector3D(), light.spotDirection()), qreal(0.0f));
+ (vertex - pli.toVector3D(), light.spotDirection()), 0.0f);
if (spot < light.spotCosAngle()) {
adcomponent = QVector4D(0, 0, 0, 0);
scomponent = QVector4D(0, 0, 0, 0);
diff --git a/tests/auto/threed/qglpainter/tst_qglpainter.cpp b/tests/auto/threed/qglpainter/tst_qglpainter.cpp
index 3034c6769..97e5a9cc3 100644
--- a/tests/auto/threed/qglpainter/tst_qglpainter.cpp
+++ b/tests/auto/threed/qglpainter/tst_qglpainter.cpp
@@ -416,7 +416,7 @@ static bool checkGLMatrix(GLenum type, const QMatrix4x4& expected)
int index;
GLfloat mat[16];
glGetFloatv(type, mat);
- qreal *m = actual.data();
+ float *m = actual.data();
for (index = 0; index < 16; ++index)
m[index] = mat[index];
for (index = 0; index < 16; ++index) {
diff --git a/tests/auto/threed/qglscenenode/tst_qglscenenode.cpp b/tests/auto/threed/qglscenenode/tst_qglscenenode.cpp
index fe26b13a8..539b14cff 100644
--- a/tests/auto/threed/qglscenenode/tst_qglscenenode.cpp
+++ b/tests/auto/threed/qglscenenode/tst_qglscenenode.cpp
@@ -723,7 +723,7 @@ void tst_QGLSceneNode::position_QTBUG_17279()
QSKIP("QWidget: Cannot create a QWidget when no GUI is being used");
QGeometryData geom;
geom.appendVertex(QVector3D(0, 0, 0),
- QVector3D(1.414, 1.414, 0),
+ QVector3D(1.414f, 1.414f, 0),
QVector3D(2, 0, 0));
TestSceneNode *node = new TestSceneNode;
@@ -759,7 +759,7 @@ void tst_QGLSceneNode::position_QTBUG_17279()
QGeometryData geom2;
geom2.appendVertex(QVector3D(0, 0, 0),
- QVector3D(-1.414, 1.414, 0),
+ QVector3D(-1.414f, 1.414f, 0),
QVector3D(-2, 0, 0));
TestSceneNode *node2 = new TestSceneNode;
node2->setGeometry(geom2);
@@ -784,7 +784,7 @@ void tst_QGLSceneNode::findSceneNode()
// +--"Item2"--""--"Item1"--"Item3"
QGeometryData geom;
geom.appendVertex(QVector3D(0, 0, 0),
- QVector3D(1.414, 1.414, 0),
+ QVector3D(1.414f, 1.414f, 0),
QVector3D(2, 0, 0));
QGLBuilder builder;
diff --git a/tests/auto/threed/qglsection/qglsection.pro b/tests/auto/threed/qglsection/qglsection.pro
index 4595c9281..6d9098599 100644
--- a/tests/auto/threed/qglsection/qglsection.pro
+++ b/tests/auto/threed/qglsection/qglsection.pro
@@ -8,3 +8,4 @@ INCLUDEPATH += ../../../shared
SOURCES += tst_qglsection.cpp
INCLUDEPATH += ../../../../src/threed/geometry
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+CONFIG+=insignificant_test # See QTBUG-27189
diff --git a/tests/auto/threed/qglsection/tst_qglsection.cpp b/tests/auto/threed/qglsection/tst_qglsection.cpp
index 4fa1fbfb5..d713216c5 100644
--- a/tests/auto/threed/qglsection/tst_qglsection.cpp
+++ b/tests/auto/threed/qglsection/tst_qglsection.cpp
@@ -275,7 +275,7 @@ void tst_QGLSection::appendFacetedMap()
// now create a new section and fill to just below the threshold for QMap
int t = section->mapThreshold();
QVector3D testVertex(-12.34f, -23.45f, -34.56f);
- QVector3D incrVector(0.02, 0.02, 0.02);
+ QVector3D incrVector(0.02f, 0.02f, 0.02f);
QVector3D testNormal(1.0f, 0.0f, 0.0f);
for (int i = 0; i < (t - 2); ++i)
{
diff --git a/tests/auto/threed/qray3d/qray3d.pro b/tests/auto/threed/qray3d/qray3d.pro
index df877ebe3..676f46e72 100644
--- a/tests/auto/threed/qray3d/qray3d.pro
+++ b/tests/auto/threed/qray3d/qray3d.pro
@@ -5,3 +5,4 @@ QT += testlib 3d
CONFIG += warn_on
SOURCES += tst_qray3d.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+CONFIG+=insignificant_test # See QTBUG-27189
diff --git a/tests/auto/threed/qray3d/tst_qray3d.cpp b/tests/auto/threed/qray3d/tst_qray3d.cpp
index 4aecb2b4c..5a93818b5 100644
--- a/tests/auto/threed/qray3d/tst_qray3d.cpp
+++ b/tests/auto/threed/qray3d/tst_qray3d.cpp
@@ -283,7 +283,7 @@ void tst_QRay3D::contains_point_data()
QTest::newRow("close to the origin")
<< QVector3D(1.0, 1.0, 1.0)
<< QVector3D(1.0, 3.0, 3.0)
- << QVector3D(1.0005, 1.0005, 1.0)
+ << QVector3D(1.0005f, 1.0005f, 1.0)
<< false;
QTest::newRow("45 line line in plane x=1")
diff --git a/tests/auto/threed/qsphere3d/tst_qsphere3d.cpp b/tests/auto/threed/qsphere3d/tst_qsphere3d.cpp
index 5f303a223..751a0a834 100644
--- a/tests/auto/threed/qsphere3d/tst_qsphere3d.cpp
+++ b/tests/auto/threed/qsphere3d/tst_qsphere3d.cpp
@@ -186,7 +186,7 @@ void tst_QSphere3D::transform()
qreal tradius = m.mapVector(QVector3D(0, radius, 0)).length();
- QCOMPARE(sphere1.center(), m * center);
+ QVERIFY(qFuzzyCompare(sphere1.center(), m * center));
QCOMPARE(float(sphere1.radius()), float(tradius));
}
diff --git a/tests/auto/threed/qtriangle3d/qtriangle3d.pro b/tests/auto/threed/qtriangle3d/qtriangle3d.pro
index 87c7e3cb2..b71b00fc2 100644
--- a/tests/auto/threed/qtriangle3d/qtriangle3d.pro
+++ b/tests/auto/threed/qtriangle3d/qtriangle3d.pro
@@ -6,3 +6,4 @@ CONFIG += warn_on
SOURCES += tst_qtriangle3d.cpp
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
+CONFIG+=insignificant_test # See QTBUG-27189