diff options
Diffstat (limited to 'tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 4d1d846eb8..0a933a1e2b 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -1,7 +1,8 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> +#include <private/qcomparisontesthelper_p.h> #include <qeasingcurve.h> @@ -16,6 +17,7 @@ private slots: void valueForProgress_data(); void valueForProgress(); void setCustomType(); + void comparisonCompiles(); void operators(); void properties(); void metaTypes(); @@ -374,7 +376,7 @@ void tst_QEasingCurve::valueForProgress() // in theory the baseline should't have an error of more than 0.00005 due to how its rounded, // but due to FP imprecision, we have to adjust the error a bit more. const qreal errorBound = 0.00006; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal error = qAbs(ex - curve.valueForProgress(at.at(i)/qreal(100))); QVERIFY(error <= errorBound); @@ -420,6 +422,11 @@ void tst_QEasingCurve::setCustomType() QCOMPARE(curve.valueForProgress(0.99), 0.99); } +void tst_QEasingCurve::comparisonCompiles() +{ + QTestPrivate::testEqualityOperatorsCompile<QEasingCurve>(); +} + void tst_QEasingCurve::operators() { { // member-swap() @@ -447,28 +454,28 @@ void tst_QEasingCurve::operators() curve2 = curve; curve2.setOvershoot(qreal(1.70158)); QCOMPARE(curve.overshoot(), curve2.overshoot()); - QVERIFY(curve2 == curve); + QT_TEST_EQUALITY_OPS(curve2, curve, true); curve.setOvershoot(3.0); - QVERIFY(curve2 != curve); + QT_TEST_EQUALITY_OPS(curve2, curve, false); curve2.setOvershoot(3.0); - QVERIFY(curve2 == curve); + QT_TEST_EQUALITY_OPS(curve2, curve, true); curve2.setType(QEasingCurve::Linear); QCOMPARE(curve.overshoot(), curve2.overshoot()); - QVERIFY(curve2 != curve); + QT_TEST_EQUALITY_OPS(curve2, curve, false); curve2.setType(QEasingCurve::InBack); QCOMPARE(curve.overshoot(), curve2.overshoot()); - QVERIFY(curve2 == curve); + QT_TEST_EQUALITY_OPS(curve2, curve, true); 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); + QT_TEST_EQUALITY_OPS(curve3, curve4, true); // default value and not assigned + QT_TEST_EQUALITY_OPS(curve3, curve5, false); // unassinged and other value + QT_TEST_EQUALITY_OPS(curve4, curve5, false); } class tst_QEasingProperties : public QObject @@ -574,18 +581,18 @@ void tst_QEasingCurve::bezierSpline_data() static inline void setupBezierSpline(QEasingCurve *easingCurve, const QString &string) { - QStringList pointStr = string.split(QLatin1Char(' ')); + const QStringList pointStr = string.split(QLatin1Char(' ')); QList<QPointF> points; - foreach (const QString &str, pointStr) { + for (const QString &str : pointStr) { QStringList coordStr = str.split(QLatin1Char(',')); QPointF point(coordStr.first().toDouble(), coordStr.last().toDouble()); points.append(point); } - QVERIFY(points.count() % 3 == 0); + QVERIFY(points.size() % 3 == 0); - for (int i = 0; i < points.count() / 3; i++) { + for (int i = 0; i < points.size() / 3; i++) { QPointF c1 = points.at(i * 3); QPointF c2 = points.at(i * 3 + 1); QPointF p1 = points.at(i * 3 + 2); @@ -603,7 +610,7 @@ void tst_QEasingCurve::bezierSpline() setupBezierSpline(&bezierEasingCurve, definition); const qreal errorBound = 0.002; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal value = bezierEasingCurve.valueForProgress(at.at(i)/qreal(100)); const qreal error = qAbs(ex - value); @@ -642,11 +649,11 @@ void tst_QEasingCurve::tcbSpline_data() static inline void setupTCBSpline(QEasingCurve *easingCurve, const QString &string) { - QStringList pointStr = string.split(QLatin1Char(' ')); + const QStringList pointStr = string.split(QLatin1Char(' ')); - foreach (const QString &str, pointStr) { + for (const QString &str : pointStr) { QStringList coordStr = str.split(QLatin1Char(',')); - Q_ASSERT(coordStr.count() == 5); + Q_ASSERT(coordStr.size() == 5); QPointF point(coordStr.first().toDouble(), coordStr.at(1).toDouble()); qreal t = coordStr.at(2).toDouble(); qreal c = coordStr.at(3).toDouble(); @@ -665,7 +672,7 @@ void tst_QEasingCurve::tcbSpline() setupTCBSpline(&tcbEasingCurve, definition); const qreal errorBound = 0.002; - for (int i = 0; i < at.count(); ++i) { + for (int i = 0; i < at.size(); ++i) { const qreal ex = expected.at(i); const qreal value = tcbEasingCurve.valueForProgress(at.at(i)/qreal(100)); const qreal error = qAbs(ex - value); @@ -890,7 +897,7 @@ void tst_QEasingCurve::streamInOut() dsw << orig; dsr >> copy; - QCOMPARE(copy == orig, equality); + QT_TEST_EQUALITY_OPS(copy, orig, equality); } QTEST_MAIN(tst_QEasingCurve) |