diff options
Diffstat (limited to 'tests/auto/gui/math3d')
-rw-r--r-- | tests/auto/gui/math3d/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 4 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qquaternion/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp | 38 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qvectornd/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp | 35 |
7 files changed, 66 insertions, 37 deletions
diff --git a/tests/auto/gui/math3d/CMakeLists.txt b/tests/auto/gui/math3d/CMakeLists.txt index 8f79355c33..a7f2a55aa1 100644 --- a/tests/auto/gui/math3d/CMakeLists.txt +++ b/tests/auto/gui/math3d/CMakeLists.txt @@ -1,8 +1,6 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# Generated from math3d.pro. - add_subdirectory(qquaternion) add_subdirectory(qvectornd) add_subdirectory(qmatrixnxn) diff --git a/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt b/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt index 319ea00cc8..22f581e9c8 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt +++ b/tests/auto/gui/math3d/qmatrixnxn/CMakeLists.txt @@ -1,12 +1,16 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# Generated from qmatrixnxn.pro. - ##################################################################### ## 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 diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index a984cd0ae7..e761f8cb3c 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> @@ -2343,7 +2343,7 @@ void tst_QMatrixNxN::rotate4x4() ROTATE4(2.0f, 3.0f, 0.0f, 1.0f, p1x, p1y, p1z, p1w); p1x /= p1w; p1y /= p1w; - p1z /= p1w; + Q_UNUSED(p1z); QVector3D v1(2.0f, 3.0f, -4.0f); QVector3D v2 = m1.map(v1); diff --git a/tests/auto/gui/math3d/qquaternion/CMakeLists.txt b/tests/auto/gui/math3d/qquaternion/CMakeLists.txt index 9d50699633..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: BSD-3-Clause -# Generated from qquaternion.pro. - ##################################################################### ## 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 ad068778b8..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: BSD-3-Clause -# Generated from qvectornd.pro. - ##################################################################### ## 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> |