summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qpoint
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-03-18 08:16:20 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-03-19 12:02:24 +0100
commit2fb0135efa97708025dab7654a8b2f1350dc30bf (patch)
tree304e6abe32e206a656757a2a46eb7e4121ce57d6 /tests/auto/corelib/tools/qpoint
parent98cbdae527b360e0e6d630848a375c6a025f572d (diff)
QSize/QPoint: add toSizeF/toPointF()
For symmetry with QSizeF::toSize(). [ChangeLog][QtCore][QSize] Added toSizeF(). [ChangeLog][QtCore][QPoint] Added toPointF(). Task-number: QTBUG-73160 Change-Id: I65b088b4f7365ab671ef2f0c75821b707f5ac26d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/corelib/tools/qpoint')
-rw-r--r--tests/auto/corelib/tools/qpoint/tst_qpoint.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
index 3ce8c3942d..30c4181d5f 100644
--- a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
+++ b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -31,6 +31,8 @@
#include <qpoint.h>
+#include <array>
+
class tst_QPoint : public QObject
{
Q_OBJECT
@@ -45,6 +47,9 @@ private slots:
void transposed();
+ void toPointF_data();
+ void toPointF();
+
void rx();
void ry();
@@ -131,6 +136,30 @@ void tst_QPoint::getSet()
QCOMPARE(point.y(), i);
}
+void tst_QPoint::toPointF_data()
+{
+ QTest::addColumn<QPoint>("input");
+ QTest::addColumn<QPointF>("result");
+
+ auto row = [](int x, int y) {
+ QTest::addRow("(%d, %d)", x, y) << QPoint(x, y) << QPointF(x, y);
+ };
+ constexpr std::array samples = {-1, 0, 1};
+ for (int x : samples) {
+ for (int y : samples) {
+ row(x, y);
+ }
+ }
+}
+
+void tst_QPoint::toPointF()
+{
+ QFETCH(const QPoint, input);
+ QFETCH(const QPointF, result);
+
+ QCOMPARE(input.toPointF(), result);
+}
+
void tst_QPoint::transposed()
{
QCOMPARE(QPoint(1, 2).transposed(), QPoint(2, 1));