summaryrefslogtreecommitdiff
path: root/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@nokia.com>2012-08-01 16:02:10 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-22 04:04:57 +0200
commit09dd19df5c4b708960e5aade568eb15d996ef200 (patch)
tree3a997704b1324dfb45f69d892128399affcac242 /tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
parent7f469ef4cc614925d7a4fdb3380ff5470e25b03b (diff)
downloadqtbase-09dd19df5c4b708960e5aade568eb15d996ef200.tar.gz
Do not consider sign in qIsNull.
The current implementation of qIsNull only returns true if the value is positive zero. This behaviour is not useful for use cases like QPointF::isNull, where QPointF(-0, -0).isNull() will return false. There doesn't seem to be a reason why the function exhibits this behaviour (-0.0 is not accounted for in the unit tests), and for the case of QSizeF::scale it causes a bug: qIsNull is used to check for division by 0.0 before it proceeds, which fails in the case of -0.0. Task-number: QTBUG-7303 Change-Id: I767e5280bd26614e8e78ae62b274eb9bc4ade385 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp')
-rw-r--r--tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
index a4e1f940fc..f42cc30fb1 100644
--- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
@@ -116,6 +116,13 @@ void tst_QQuaternion::create()
QCOMPARE(identity.scalar(), (qreal)1.0f);
QVERIFY(identity.isIdentity());
+ QQuaternion negativeZeroIdentity(qreal(1.0), qreal(-0.0), qreal(-0.0), qreal(-0.0));
+ QCOMPARE(negativeZeroIdentity.x(), qreal(-0.0));
+ QCOMPARE(negativeZeroIdentity.y(), qreal(-0.0));
+ QCOMPARE(negativeZeroIdentity.z(), qreal(-0.0));
+ QCOMPARE(negativeZeroIdentity.scalar(), qreal(1.0));
+ QVERIFY(negativeZeroIdentity.isIdentity());
+
QQuaternion v1(34.0f, 1.0f, 2.5f, -89.25f);
QCOMPARE(v1.x(), (qreal)1.0f);
QCOMPARE(v1.y(), (qreal)2.5f);