diff options
Diffstat (limited to 'tests/auto/gui/math3d')
-rw-r--r-- | tests/auto/gui/math3d/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt | 12 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 177 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qquaternion/CMakeLists.txt | 10 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp | 38 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qvectornd/CMakeLists.txt | 10 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp | 35 |
7 files changed, 191 insertions, 95 deletions
diff --git a/tests/auto/gui/math3d/CMakeLists.txt b/tests/auto/gui/math3d/CMakeLists.txt index eb6e87d4a4..a7f2a55aa1 100644 --- a/tests/auto/gui/math3d/CMakeLists.txt +++ b/tests/auto/gui/math3d/CMakeLists.txt @@ -1,7 +1,5 @@ # Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -# Generated from math3d.pro. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(qquaternion) add_subdirectory(qvectornd) diff --git a/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt b/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt index 7e3b0fd93f..22f581e9c8 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt +++ b/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt @@ -1,17 +1,19 @@ # Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -# Generated from qmatrixnxn.pro. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qmatrixnxn Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qmatrixnxn LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_qmatrixnxn SOURCES tst_qmatrixnxn.cpp - DEFINES - QT_DISABLE_DEPRECATED_BEFORE=0 LIBRARIES Qt::Gui ) diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 29c5248fe3..38ecaa7e44 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 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 <QTest> #include <QtCore/qmath.h> @@ -100,6 +100,7 @@ private slots: void rotate4x4_data(); void rotate4x4(); + void projectedRotate(); void normalMatrix_data(); void normalMatrix(); @@ -132,6 +133,11 @@ private slots: void properties(); void metaTypes(); + // Tests for deprecated APIs +#if QT_DEPRECATED_SINCE(6, 1) + void deprecatedMultiplications(); +#endif + private: static void setMatrix(QMatrix2x2& m, const float *values); static void setMatrixDirect(QMatrix2x2& m, const float *values); @@ -1969,12 +1975,7 @@ void tst_QMatrixNxN::scale4x4() } QVector3D v1(2.0f, 3.0f, -4.0f); - QVector3D v2 = m1 * v1; - QCOMPARE(v2.x(), (float)(2.0f * x)); - QCOMPARE(v2.y(), (float)(3.0f * y)); - QCOMPARE(v2.z(), (float)(-4.0f * z)); - - v2 = v1 * m1; + QVector3D v2 = m1.map(v1); QCOMPARE(v2.x(), (float)(2.0f * x)); QCOMPARE(v2.y(), (float)(3.0f * y)); QCOMPARE(v2.z(), (float)(-4.0f * z)); @@ -1993,7 +1994,7 @@ void tst_QMatrixNxN::scale4x4() QCOMPARE(v4.w(), (float)34.0f); QPoint p1(2, 3); - QPoint p2 = m1 * p1; + QPoint p2 = m1.map(p1); QCOMPARE(p2.x(), (int)(2.0f * x)); QCOMPARE(p2.y(), (int)(3.0f * y)); @@ -2002,7 +2003,7 @@ void tst_QMatrixNxN::scale4x4() QCOMPARE(p2.y(), (int)(3.0f * y)); QPointF p3(2.0f, 3.0f); - QPointF p4 = m1 * p3; + QPointF p4 = m1.map(p3); QCOMPARE(p4.x(), (float)(2.0f * x)); QCOMPARE(p4.y(), (float)(3.0f * y)); @@ -2115,7 +2116,7 @@ void tst_QMatrixNxN::translate4x4() } QVector3D v1(2.0f, 3.0f, -4.0f); - QVector3D v2 = m1 * v1; + QVector3D v2 = m1.map(v1); QCOMPARE(v2.x(), (float)(2.0f + x)); QCOMPARE(v2.y(), (float)(3.0f + y)); QCOMPARE(v2.z(), (float)(-4.0f + z)); @@ -2135,12 +2136,12 @@ void tst_QMatrixNxN::translate4x4() QCOMPARE(v6.w(), (float)34.0f); QPoint p1(2, 3); - QPoint p2 = m1 * p1; + QPoint p2 = m1.map(p1); QCOMPARE(p2.x(), (int)(2.0f + x)); QCOMPARE(p2.y(), (int)(3.0f + y)); QPointF p3(2.0f, 3.0f); - QPointF p4 = m1 * p3; + QPointF p4 = m1.map(p3); QCOMPARE(p4.x(), (float)(2.0f + x)); QCOMPARE(p4.y(), (float)(3.0f + y)); @@ -2345,7 +2346,7 @@ void tst_QMatrixNxN::rotate4x4() p1z /= p1w; QVector3D v1(2.0f, 3.0f, -4.0f); - QVector3D v2 = m1 * v1; + QVector3D v2 = m1.map(v1); QVERIFY(qFuzzyCompare(v2.x(), v1x)); QVERIFY(qFuzzyCompare(v2.y(), v1y)); QVERIFY(qFuzzyCompare(v2.z(), v1z)); @@ -2365,12 +2366,12 @@ void tst_QMatrixNxN::rotate4x4() QVERIFY(qFuzzyCompare(v6.w(), v5w)); QPoint p1(2, 3); - QPoint p2 = m1 * p1; + QPoint p2 = m1.map(p1); QCOMPARE(p2.x(), qRound(p1x)); QCOMPARE(p2.y(), qRound(p1y)); QPointF p3(2.0f, 3.0f); - QPointF p4 = m1 * p3; + QPointF p4 = m1.map(p3); QVERIFY(qFuzzyCompare(float(p4.x()), p1x)); QVERIFY(qFuzzyCompare(float(p4.y()), p1y)); @@ -2383,6 +2384,22 @@ void tst_QMatrixNxN::rotate4x4() } } +void tst_QMatrixNxN::projectedRotate() +{ + QMatrix4x4 m1, m2; + const QPointF origin(1000, 1000); + + m1.translate(origin.x(), origin.y()); + m1.projectedRotate(60, 0, 1, 0, 0); + m1.translate(-origin.x(), -origin.y()); + + m2.translate(origin.x(), origin.y()); + m2.rotate(60, 0, 1, 0); + m2.translate(-origin.x(), -origin.y()); + + QCOMPARE(m1.toTransform(), m2.toTransform()); +} + static bool isSame(const QMatrix3x3& m1, const Matrix3& m2) { for (int row = 0; row < 3; ++row) { @@ -2604,11 +2621,11 @@ void tst_QMatrixNxN::ortho() { QMatrix4x4 m1; m1.ortho(QRect(0, 0, 300, 150)); - QPointF p1 = m1 * QPointF(0, 0); - QPointF p2 = m1 * QPointF(300, 0); - QPointF p3 = m1 * QPointF(0, 150); - QPointF p4 = m1 * QPointF(300, 150); - QVector3D p5 = m1 * QVector3D(300, 150, 1); + QPointF p1 = m1.map(QPointF(0, 0)); + QPointF p2 = m1.map(QPointF(300, 0)); + QPointF p3 = m1.map(QPointF(0, 150)); + QPointF p4 = m1.map(QPointF(300, 150)); + QVector3D p5 = m1.map(QVector3D(300, 150, 1)); QVERIFY(qFuzzyCompare(float(p1.x()), -1.0f)); QVERIFY(qFuzzyCompare(float(p1.y()), 1.0f)); QVERIFY(qFuzzyCompare(float(p2.x()), 1.0f)); @@ -2623,11 +2640,11 @@ void tst_QMatrixNxN::ortho() QMatrix4x4 m2; m2.ortho(QRectF(0, 0, 300, 150)); - p1 = m2 * QPointF(0, 0); - p2 = m2 * QPointF(300, 0); - p3 = m2 * QPointF(0, 150); - p4 = m2 * QPointF(300, 150); - p5 = m2 * QVector3D(300, 150, 1); + p1 = m2.map(QPointF(0, 0)); + p2 = m2.map(QPointF(300, 0)); + p3 = m2.map(QPointF(0, 150)); + p4 = m2.map(QPointF(300, 150)); + p5 = m2.map(QVector3D(300, 150, 1)); QVERIFY(qFuzzyCompare(float(p1.x()), -1.0f)); QVERIFY(qFuzzyCompare(float(p1.y()), 1.0f)); QVERIFY(qFuzzyCompare(float(p2.x()), 1.0f)); @@ -2642,11 +2659,11 @@ void tst_QMatrixNxN::ortho() QMatrix4x4 m3; m3.ortho(0, 300, 150, 0, -1, 1); - p1 = m3 * QPointF(0, 0); - p2 = m3 * QPointF(300, 0); - p3 = m3 * QPointF(0, 150); - p4 = m3 * QPointF(300, 150); - p5 = m3 * QVector3D(300, 150, 1); + p1 = m3.map(QPointF(0, 0)); + p2 = m3.map(QPointF(300, 0)); + p3 = m3.map(QPointF(0, 150)); + p4 = m3.map(QPointF(300, 150)); + p5 = m3.map(QVector3D(300, 150, 1)); QVERIFY(qFuzzyCompare(float(p1.x()), -1.0f)); QVERIFY(qFuzzyCompare(float(p1.y()), 1.0f)); QVERIFY(qFuzzyCompare(float(p2.x()), 1.0f)); @@ -2661,11 +2678,11 @@ void tst_QMatrixNxN::ortho() QMatrix4x4 m4; m4.ortho(0, 300, 150, 0, -2, 3); - p1 = m4 * QPointF(0, 0); - p2 = m4 * QPointF(300, 0); - p3 = m4 * QPointF(0, 150); - p4 = m4 * QPointF(300, 150); - p5 = m4 * QVector3D(300, 150, 1); + p1 = m4.map(QPointF(0, 0)); + p2 = m4.map(QPointF(300, 0)); + p3 = m4.map(QPointF(0, 150)); + p4 = m4.map(QPointF(300, 150)); + p5 = m4.map(QVector3D(300, 150, 1)); QVERIFY(qFuzzyCompare(float(p1.x()), -1.0f)); QVERIFY(qFuzzyCompare(float(p1.y()), 1.0f)); QVERIFY(qFuzzyCompare(float(p2.x()), 1.0f)); @@ -2693,11 +2710,11 @@ void tst_QMatrixNxN::frustum() { QMatrix4x4 m1; m1.frustum(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); - QVector3D p1 = m1 * QVector3D(-1.0f, -1.0f, 1.0f); - QVector3D p2 = m1 * QVector3D(1.0f, -1.0f, 1.0f); - QVector3D p3 = m1 * QVector3D(-1.0f, 1.0f, 1.0f); - QVector3D p4 = m1 * QVector3D(1.0f, 1.0f, 1.0f); - QVector3D p5 = m1 * QVector3D(0.0f, 0.0f, 2.0f); + QVector3D p1 = m1.map(QVector3D(-1.0f, -1.0f, 1.0f)); + QVector3D p2 = m1.map(QVector3D(1.0f, -1.0f, 1.0f)); + QVector3D p3 = m1.map(QVector3D(-1.0f, 1.0f, 1.0f)); + QVector3D p4 = m1.map(QVector3D(1.0f, 1.0f, 1.0f)); + QVector3D p5 = m1.map(QVector3D(0.0f, 0.0f, 2.0f)); QVERIFY(qFuzzyCompare(p1.x(), -1.0f)); QVERIFY(qFuzzyCompare(p1.y(), -1.0f)); QVERIFY(qFuzzyCompare(p1.z(), -1.0f)); @@ -2729,11 +2746,11 @@ void tst_QMatrixNxN::perspective() { QMatrix4x4 m1; m1.perspective(45.0f, 1.0f, -1.0f, 1.0f); - QVector3D p1 = m1 * QVector3D(-1.0f, -1.0f, 1.0f); - QVector3D p2 = m1 * QVector3D(1.0f, -1.0f, 1.0f); - QVector3D p3 = m1 * QVector3D(-1.0f, 1.0f, 1.0f); - QVector3D p4 = m1 * QVector3D(1.0f, 1.0f, 1.0f); - QVector3D p5 = m1 * QVector3D(0.0f, 0.0f, 2.0f); + QVector3D p1 = m1.map(QVector3D(-1.0f, -1.0f, 1.0f)); + QVector3D p2 = m1.map(QVector3D(1.0f, -1.0f, 1.0f)); + QVector3D p3 = m1.map(QVector3D(-1.0f, 1.0f, 1.0f)); + QVector3D p4 = m1.map(QVector3D(1.0f, 1.0f, 1.0f)); + QVector3D p5 = m1.map(QVector3D(0.0f, 0.0f, 2.0f)); QVERIFY(qFuzzyCompare(p1.x(), 2.41421f)); QVERIFY(qFuzzyCompare(p1.y(), 2.41421f)); QVERIFY(qFuzzyCompare(p1.z(), -1.0f)); @@ -2799,25 +2816,25 @@ void tst_QMatrixNxN::flipCoordinates() { QMatrix4x4 m1; m1.flipCoordinates(); - QVector3D p1 = m1 * QVector3D(2, 3, 4); + QVector3D p1 = m1.map(QVector3D(2, 3, 4)); QVERIFY(p1 == QVector3D(2, -3, -4)); QMatrix4x4 m2; m2.scale(2.0f, 3.0f, 1.0f); m2.flipCoordinates(); - QVector3D p2 = m2 * QVector3D(2, 3, 4); + QVector3D p2 = m2.map(QVector3D(2, 3, 4)); QVERIFY(p2 == QVector3D(4, -9, -4)); QMatrix4x4 m3; m3.translate(2.0f, 3.0f, 1.0f); m3.flipCoordinates(); - QVector3D p3 = m3 * QVector3D(2, 3, 4); + QVector3D p3 = m3.map(QVector3D(2, 3, 4)); QVERIFY(p3 == QVector3D(4, 0, -3)); QMatrix4x4 m4; m4.rotate(90.0f, 0.0f, 0.0f, 1.0f); m4.flipCoordinates(); - QVector3D p4 = m4 * QVector3D(2, 3, 4); + QVector3D p4 = m4.map(QVector3D(2, 3, 4)); QVERIFY(p4 == QVector3D(3, 2, -4)); } @@ -3019,7 +3036,7 @@ void tst_QMatrixNxN::convertQTransform() QCOMPARE(p1.y(), 150.0 + 2.0); QMatrix4x4 m2(m1); - QPointF p2 = m2 * QPointF(100.0, 150.0); + QPointF p2 = m2.map(QPointF(100.0, 150.0)); QCOMPARE((double)p2.x(), 100.0 - 3.5); QCOMPARE((double)p2.y(), 150.0 + 2.0); QCOMPARE(m1, m2.toTransform()); @@ -3031,7 +3048,7 @@ void tst_QMatrixNxN::convertQTransform() QCOMPARE(p3.y(), -2.0 * 150.0); QMatrix4x4 m4(m3); - QPointF p4 = m4 * QPointF(100.0, 150.0); + QPointF p4 = m4.map(QPointF(100.0, 150.0)); QCOMPARE((double)p4.x(), 1.5 * 100.0); QCOMPARE((double)p4.y(), -2.0 * 150.0); QCOMPARE(m3, m4.toTransform()); @@ -3041,7 +3058,7 @@ void tst_QMatrixNxN::convertQTransform() QPointF p5 = m5.map(QPointF(100.0, 150.0)); QMatrix4x4 m6(m5); - QPointF p6 = m6 * QPointF(100.0, 150.0); + QPointF p6 = m6.map(QPointF(100.0, 150.0)); QVERIFY(qFuzzyCompare(float(p5.x()), float(p6.x()))); QVERIFY(qFuzzyCompare(float(p5.y()), float(p6.y()))); @@ -3291,9 +3308,9 @@ void tst_QMatrixNxN::properties() void tst_QMatrixNxN::metaTypes() { - QCOMPARE(QMetaType::type("QMatrix4x4"), int(QMetaType::QMatrix4x4)); + QCOMPARE(QMetaType::fromName("QMatrix4x4").id(), int(QMetaType::QMatrix4x4)); - QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)), + QCOMPARE(QByteArray(QMetaType(QMetaType::QMatrix4x4).name()), QByteArray("QMatrix4x4")); QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4)); @@ -3301,6 +3318,58 @@ void tst_QMatrixNxN::metaTypes() QCOMPARE(qMetaTypeId<QMatrix4x4>(), int(QMetaType::QMatrix4x4)); } +#if QT_DEPRECATED_SINCE(6, 1) +void tst_QMatrixNxN::deprecatedMultiplications() +{ + QMatrix4x4 m; + m.scale(1.0f, 2.0f, 3.0f); + // QMatrix4x4 and QVector3D + { + QVector3D v(4.0f, 5.0f, 6.0f); + { + // QMatrix4x4 * QVector3D + QT_IGNORE_DEPRECATIONS(const QVector3D v1 = m * v;) + const QVector3D v2 = m.map(v); + + QCOMPARE(v1.x(), v2.x()); + QCOMPARE(v1.y(), v2.y()); + QCOMPARE(v1.z(), v2.z()); + } + { + // QVector3D * QMatrix4x4 + QT_IGNORE_DEPRECATIONS(const QVector3D v1 = v * m;) + + QVector4D v4(v, 1.0); + const QVector4D v2 = v4 * m; + + QCOMPARE(v1.x(), v2.x()); + QCOMPARE(v1.y(), v2.y()); + QCOMPARE(v1.z(), v2.z()); + } + } + { + // QMatrix4x4 * QPoint + const QPoint p(4, 5); + + QT_IGNORE_DEPRECATIONS(const QPoint p1 = m * p;) + const QPoint p2 = m.map(p); + + QCOMPARE(p1.x(), p2.x()); + QCOMPARE(p1.y(), p2.y()); + } + { + // QMatrix4x4 * QPointF + const QPointF p(4.0f, 5.0f); + + QT_IGNORE_DEPRECATIONS(const QPointF p1 = m * p;) + const QPointF p2 = m.map(p); + + QCOMPARE(p1.x(), p2.x()); + QCOMPARE(p1.y(), p2.y()); + } +} +#endif // QT_DEPRECATED_SINCE(6, 1) + QTEST_APPLESS_MAIN(tst_QMatrixNxN) #include "tst_qmatrixnxn.moc" diff --git a/tests/auto/gui/math3d/qquaternion/CMakeLists.txt b/tests/auto/gui/math3d/qquaternion/CMakeLists.txt index 52912278a2..205865faba 100644 --- a/tests/auto/gui/math3d/qquaternion/CMakeLists.txt +++ b/tests/auto/gui/math3d/qquaternion/CMakeLists.txt @@ -1,12 +1,16 @@ # Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -# Generated from qquaternion.pro. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qquaternion Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qquaternion LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_qquaternion SOURCES tst_qquaternion.cpp diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp index 350be3da6a..8cdc06354e 100644 --- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp @@ -1,5 +1,7 @@ // Copyright (C) 2016 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 + +#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses #include <QTest> #include <QtCore/qmath.h> @@ -575,7 +577,7 @@ void tst_QQuaternion::multiply_data() for (float x = -1.0f; x <= 1.0f; x += 0.5f) for (float y = -1.0f; y <= 1.0f; y += 0.5f) for (float z = -1.0f; z <= 1.0f; z += 0.5f) { - QTest::newRow("exhaustive") + QTest::addRow("exhaustive: (%.1f, %.1f, %.1f), %.1f", x, y, z, w) << x << y << z << w << z << w << y << x; } @@ -962,28 +964,6 @@ void tst_QQuaternion::rotationTo() QVERIFY(myFuzzyCompare(vec2, from)); } -static QByteArray testnameForAxis(const QVector3D &axis) -{ - QByteArray testname; - if (axis == QVector3D()) { - testname = "null"; - } else { - if (axis.x()) { - testname += axis.x() < 0 ? '-' : '+'; - testname += 'X'; - } - if (axis.y()) { - testname += axis.y() < 0 ? '-' : '+'; - testname += 'Y'; - } - if (axis.z()) { - testname += axis.z() < 0 ? '-' : '+'; - testname += 'Z'; - } - } - return testname; -} - // Test quaternion convertion to and from orthonormal axes. void tst_QQuaternion::fromDirection_data() { @@ -1006,7 +986,10 @@ void tst_QQuaternion::fromDirection_data() QVector3D xAxis, yAxis, zAxis; q.getAxes(&xAxis, &yAxis, &zAxis); - QTest::newRow("dir: " + testnameForAxis(zAxis) + ", up: " + testnameForAxis(yAxis)) + QTest::addRow("ortho dirs: (%.1f,%.1f,%.1f), (%.1f,%.1f,%.1f), (%.1f,%.1f,%.1f)", + xAxis.x(), xAxis.y(), xAxis.z(), + yAxis.x(), yAxis.y(), yAxis.z(), + zAxis.x(), zAxis.y(), zAxis.z()) << zAxis * 10.0f << yAxis * 10.0f; } @@ -1025,7 +1008,10 @@ void tst_QQuaternion::fromDirection_data() QVector3D xAxis, yAxis, zAxis; q.getAxes(&xAxis, &yAxis, &zAxis); - QTest::newRow("dir: " + testnameForAxis(zAxis) + ", up: null") + QTest::addRow("bad dirs: (%.1f,%.1f,%.1f), (%.1f,%.1f,%.1f), (%.1f,%.1f,%.1f)", + xAxis.x(), xAxis.y(), xAxis.z(), + yAxis.x(), yAxis.y(), yAxis.z(), + zAxis.x(), zAxis.y(), zAxis.z()) << zAxis * 10.0f << QVector3D(); } } diff --git a/tests/auto/gui/math3d/qvectornd/CMakeLists.txt b/tests/auto/gui/math3d/qvectornd/CMakeLists.txt index dd12355d3c..5de1ff11e6 100644 --- a/tests/auto/gui/math3d/qvectornd/CMakeLists.txt +++ b/tests/auto/gui/math3d/qvectornd/CMakeLists.txt @@ -1,12 +1,16 @@ # Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -# Generated from qvectornd.pro. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qvectornd Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qvectornd LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_qvectornd SOURCES tst_qvectornd.cpp diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp index ade6eba796..3272ffac0e 100644 --- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp @@ -1,5 +1,38 @@ // Copyright (C) 2016 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 <QVector2D> +#include <QVector3D> +#include <QVector4D> +#ifdef QVARIANT_H +# error "This test requires qvector{2,3,4}d.h to not include qvariant.h" +#endif + +// 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<QVector2D cvref >())), float cvref >); \ + static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector2D cvref >())), float cvref >); \ + \ + static_assert(my_is_same_v<decltype(get<0>(std::declval<QVector3D cvref >())), float cvref >); \ + static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector3D cvref >())), float cvref >); \ + static_assert(my_is_same_v<decltype(get<2>(std::declval<QVector3D cvref >())), float cvref >); \ + \ + static_assert(my_is_same_v<decltype(get<0>(std::declval<QVector4D cvref >())), float cvref >); \ + static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector4D cvref >())), float cvref >); \ + static_assert(my_is_same_v<decltype(get<2>(std::declval<QVector4D cvref >())), float cvref >); \ + static_assert(my_is_same_v<decltype(get<3>(std::declval<QVector4D cvref >())), float cvref >) + +CHECK(&); +CHECK(const &); +CHECK(&&); +CHECK(const &&); + +#undef CHECK #include <QTest> #include <QtCore/qmath.h> |