summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qpointf/tst_qpointf.cpp')
-rw-r--r--tests/auto/corelib/tools/qpointf/tst_qpointf.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
index 0f2e74e68e..fc79b40a18 100644
--- a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
+++ b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
@@ -75,6 +75,9 @@ private slots:
void operator_divide();
void division();
+ void dotProduct_data();
+ void dotProduct();
+
void operator_unary_plus_data();
void operator_unary_plus();
@@ -290,6 +293,29 @@ void tst_QPointF::division()
}
}
+void tst_QPointF::dotProduct_data()
+{
+ QTest::addColumn<QPointF>("point1");
+ QTest::addColumn<QPointF>("point2");
+ QTest::addColumn<qreal>("expected");
+
+ QTest::newRow("(0, 0) dot (0, 0)") << QPointF(0, 0) << QPointF(0, 0) << qreal(0);
+ QTest::newRow("(10, 0) dot (0, 10)") << QPointF(10, 0) << QPointF(0, 10)<< qreal(0);
+ QTest::newRow("(0, 10) dot (10, 0)") << QPointF(0, 10) << QPointF(10, 0) << qreal(0);
+ QTest::newRow("(10, 20) dot (-10, -20)") << QPointF(10, 20) << QPointF(-10, -20) << qreal(-500);
+ QTest::newRow("(10.1, 20.2) dot (-10.1, -20.2)") << QPointF(10.1, 20.2) << QPointF(-10.1, -20.2) << qreal(-510.05);
+ QTest::newRow("(-10.1, -20.2) dot (10.1, 20.2)") << QPointF(-10.1, -20.2) << QPointF(10.1, 20.2) << qreal(-510.05);
+}
+
+void tst_QPointF::dotProduct()
+{
+ QFETCH(QPointF, point1);
+ QFETCH(QPointF, point2);
+ QFETCH(qreal, expected);
+
+ QCOMPARE(QPointF::dotProduct(point1, point2), expected);
+}
+
void tst_QPointF::operator_unary_plus_data()
{
operator_unary_minus_data();