summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2024-03-22 10:50:12 +0100
committerIvan Solovev <ivan.solovev@qt.io>2024-05-10 15:33:39 +0200
commitfa0d77e290f5ccb5afa7d02716f8726aa6b810e6 (patch)
treea2c134cace3c0fa290f80edc73c470a0f49cda99 /tests/auto/corelib
parentd999e646929889a0e25df2be4a097196c9ea3a49 (diff)
Add qFuzzyCompare() and qFuzzyIsNull() overloads for QPointF
Use the new qFuzzyCompare() overload in op==(QPointF, QPointF). [ChangeLog][QtCore][QPointF] Added qFuzzyCompare() and qFuzzyIsNull() overloads for QPointF. Task-number: QTBUG-120308 Change-Id: I522164acb65432bf55c58b55575f25535d27e27a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/tools/qpointf/tst_qpointf.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
index e75dd9d5ab..ebbac4ec7c 100644
--- a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
+++ b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
@@ -76,6 +76,9 @@ private slots:
void operator_eq_data();
void operator_eq();
+ void fuzzyCompare_data();
+ void fuzzyCompare();
+
void toPoint_data();
void toPoint();
@@ -103,15 +106,19 @@ void tst_QPointF::isNull()
{
QPointF point(0, 0);
QVERIFY(point.isNull());
+ QVERIFY(qFuzzyIsNull(point));
++point.rx();
QVERIFY(!point.isNull());
+ QVERIFY(!qFuzzyIsNull(point));
point.rx() -= 2;
QVERIFY(!point.isNull());
+ QVERIFY(!qFuzzyIsNull(point));
QPointF nullNegativeZero(qreal(-0.0), qreal(-0.0));
QCOMPARE(nullNegativeZero.x(), (qreal)-0.0f);
QCOMPARE(nullNegativeZero.y(), (qreal)-0.0f);
QVERIFY(nullNegativeZero.isNull());
+ QVERIFY(qFuzzyIsNull(nullNegativeZero));
}
void tst_QPointF::manhattanLength_data()
@@ -385,6 +392,20 @@ void tst_QPointF::operator_eq()
QT_TEST_EQUALITY_OPS(point1, intPoint2, expectIntEqual);
}
+void tst_QPointF::fuzzyCompare_data()
+{
+ operator_eq_data();
+}
+
+void tst_QPointF::fuzzyCompare()
+{
+ QFETCH(QPointF, point1);
+ QFETCH(QPointF, point2);
+ QFETCH(bool, expectEqual);
+
+ QCOMPARE_EQ(qFuzzyCompare(point1, point2), expectEqual);
+}
+
void tst_QPointF::toPoint_data()
{
QTest::addColumn<QPointF>("pointf");