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.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
index 924cac292e..3231469261 100644
--- a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
+++ b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp
@@ -70,6 +70,9 @@ private slots:
void operator_divide_data();
void operator_divide();
+ void dotProduct_data();
+ void dotProduct();
+
void operator_unary_plus_data();
void operator_unary_plus();
@@ -271,6 +274,28 @@ void tst_QPoint::operator_divide()
QCOMPARE(point, expected);
}
+void tst_QPoint::dotProduct_data()
+{
+ QTest::addColumn<QPoint>("point1");
+ QTest::addColumn<QPoint>("point2");
+ QTest::addColumn<int>("expected");
+
+ QTest::newRow("(0, 0) dot (0, 0)") << QPoint(0, 0) << QPoint(0, 0)<< 0;
+ QTest::newRow("(10, 0) dot (0, 10)") << QPoint(10, 0) << QPoint(0, 10) << 0;
+ QTest::newRow("(0, 10) dot (10, 0)") << QPoint(0, 10) << QPoint(10, 0) << 0;
+ QTest::newRow("(10, 20) dot (-10, -20)") << QPoint(10, 20) << QPoint(-10, -20) << -500;
+ QTest::newRow("(-10, -20) dot (10, 20)") << QPoint(-10, -20) << QPoint(10, 20) << -500;
+}
+
+void tst_QPoint::dotProduct()
+{
+ QFETCH(QPoint, point1);
+ QFETCH(QPoint, point2);
+ QFETCH(int, expected);
+
+ QCOMPARE(QPoint::dotProduct(point1, point2), expected);
+}
+
void tst_QPoint::operator_unary_plus_data()
{
operator_unary_minus_data();