summaryrefslogtreecommitdiffstats
path: root/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2010-09-08 09:09:52 (GMT)
committerFrederik Gladhorn <frederik.gladhorn@nokia.com>2010-09-08 09:49:02 (GMT)
commit87c1a9b5a2d9ba03bcc2ae9a74a9c3a7ff8fe09a (patch)
tree62b773734714ebe9ddbf033f49b23d025ead1992 /tests/auto/qeasingcurve/tst_qeasingcurve.cpp
parent3d247e0ae09bcd1b75f92a587ab5b28569a3f0f6 (diff)
downloadQt-87c1a9b5a2d9ba03bcc2ae9a74a9c3a7ff8fe09a.zip
Qt-87c1a9b5a2d9ba03bcc2ae9a74a9c3a7ff8fe09a.tar.gz
Qt-87c1a9b5a2d9ba03bcc2ae9a74a9c3a7ff8fe09a.tar.bz2
QEasingCurve::operator== returning wrong value
Comparisons between just constructed QEasingCurve and ones that had a value (eg amplitude) set, would always return true. At the same time we still need to make operator== work without creating the private config object (QEasingCurveFunction). In order to make comparisons work in all cases, remove all explicit float constants (3.0f) and instead use qreal(0.3). Task-number: QTBUG-12274 Reviewed-by: Thierry
Diffstat (limited to 'tests/auto/qeasingcurve/tst_qeasingcurve.cpp')
-rw-r--r--tests/auto/qeasingcurve/tst_qeasingcurve.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
index 124f900..2411ab6 100644
--- a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
+++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp
@@ -153,19 +153,19 @@ void tst_QEasingCurve::propertyDefaults()
QEasingCurve curve(QEasingCurve::InElastic);
QCOMPARE(curve.period(), 0.3);
QCOMPARE(curve.amplitude(), 1.0);
- QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), qreal(1.70158));
curve.setType(QEasingCurve::InBounce);
QCOMPARE(curve.period(), 0.3);
QCOMPARE(curve.amplitude(), 1.0);
- QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), qreal(1.70158));
curve.setType(QEasingCurve::Linear);
QCOMPARE(curve.period(), 0.3);
QCOMPARE(curve.amplitude(), 1.0);
- QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), qreal(1.70158));
curve.setType(QEasingCurve::InElastic);
QCOMPARE(curve.period(), 0.3);
QCOMPARE(curve.amplitude(), 1.0);
- QCOMPARE(curve.overshoot(), qreal(1.70158f));
+ QCOMPARE(curve.overshoot(), qreal(1.70158));
curve.setPeriod(0.4);
curve.setAmplitude(0.6);
curve.setOvershoot(1.0);
@@ -490,7 +490,7 @@ void tst_QEasingCurve::operators()
// operator==
curve.setType(QEasingCurve::InBack);
curve2 = curve;
- curve2.setOvershoot(qreal(1.70158f));
+ curve2.setOvershoot(qreal(1.70158));
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
@@ -505,6 +505,15 @@ void tst_QEasingCurve::operators()
curve2.setType(QEasingCurve::InBack);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
+
+ QEasingCurve curve3;
+ QEasingCurve curve4;
+ curve4.setAmplitude(curve4.amplitude());
+ QEasingCurve curve5;
+ curve5.setAmplitude(0.12345);
+ QVERIFY(curve3 == curve4); // default value and not assigned
+ QVERIFY(curve3 != curve5); // unassinged and other value
+ QVERIFY(curve4 != curve5);
}
class tst_QEasingProperties : public QObject
@@ -527,7 +536,7 @@ void tst_QEasingCurve::properties()
tst_QEasingProperties obj;
QEasingCurve inOutBack(QEasingCurve::InOutBack);
- qreal overshoot = 1.5f;
+ qreal overshoot = 1.5;
inOutBack.setOvershoot(overshoot);
qreal amplitude = inOutBack.amplitude();
qreal period = inOutBack.period();