summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qpoint/tst_qpoint.cpp')
-rw-r--r--tests/auto/corelib/tools/qpoint/tst_qpoint.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
index c183f79fb8..4763c1bf07 100644
--- a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
+++ b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
@@ -1,5 +1,28 @@
// Copyright (C) 2022 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 <QPoint>
+#ifdef QVARIANT_H
+# error "This test requires qpoint.h to not include qvariant.h"
+#endif
+#include <private/qcomparisontesthelper_p.h>
+
+// don't assume <type_traits>
+template <typename T, typename U>
+constexpr inline bool my_is_same_v = false;
+template <typename T>
+constexpr inline bool my_is_same_v<T, T> = true;
+
+#define CHECK(cvref) \
+ static_assert(my_is_same_v<decltype(get<0>(std::declval<QPoint cvref >())), int cvref >); \
+ static_assert(my_is_same_v<decltype(get<1>(std::declval<QPoint cvref >())), int cvref >)
+
+CHECK(&);
+CHECK(const &);
+CHECK(&&);
+CHECK(const &&);
+
+#undef CHECK
#include <QTest>
#include <QBuffer>
@@ -49,6 +72,7 @@ private slots:
void operator_unary_minus_data();
void operator_unary_minus();
+ void operatorsCompile();
void operator_eq_data();
void operator_eq();
@@ -133,6 +157,8 @@ void tst_QPoint::toPointF()
QFETCH(const QPointF, result);
QCOMPARE(input.toPointF(), result);
+ // test also mixed-type comparison
+ QT_TEST_EQUALITY_OPS(input, result, true);
}
void tst_QPoint::transposed()
@@ -328,6 +354,12 @@ void tst_QPoint::operator_unary_minus()
QCOMPARE(-point, expected);
}
+void tst_QPoint::operatorsCompile()
+{
+ // Mixed-type comparison is tested in tst_QPointF.
+ QTestPrivate::testEqualityOperatorsCompile<QPoint>();
+}
+
void tst_QPoint::operator_eq_data()
{
QTest::addColumn<QPoint>("point1");
@@ -349,12 +381,9 @@ void tst_QPoint::operator_eq()
QFETCH(QPoint, point2);
QFETCH(bool, expectEqual);
- bool equal = point1 == point2;
- QCOMPARE(equal, expectEqual);
- bool notEqual = point1 != point2;
- QCOMPARE(notEqual, !expectEqual);
+ QT_TEST_EQUALITY_OPS(point1, point2, expectEqual);
- if (equal)
+ if (expectEqual)
QCOMPARE(qHash(point1), qHash(point2));
}