diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp index 8cdc06354e2..06b6ffc2700 100644 --- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp @@ -1,8 +1,6 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses - #include #include #include @@ -970,19 +968,23 @@ void tst_QQuaternion::fromDirection_data() QTest::addColumn("direction"); QTest::addColumn("up"); - QList orientations; - orientations << QQuaternion(); + // 1 default constructed element + 360/45 loops, each adding 4 elements + constexpr int size = 1 + (360 / 45) * 4; + std::array orientations; + orientations[0] = {}; + int n = 0; for (int angle = 45; angle <= 360; angle += 45) { - orientations << QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), angle) - << QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), angle) - << QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), angle) - << QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), angle) - * QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), angle) - * QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), angle); + orientations[++n] = QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), angle); + orientations[++n] = QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), angle); + orientations[++n] = QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), angle); + orientations[++n] = QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), angle) + * QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), angle) + * QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), angle); } + QCOMPARE(n, size - 1); // othonormal up and dir - foreach (const QQuaternion &q, orientations) { + for (QQuaternion q : orientations) { QVector3D xAxis, yAxis, zAxis; q.getAxes(&xAxis, &yAxis, &zAxis); @@ -1004,7 +1006,7 @@ void tst_QQuaternion::fromDirection_data() QTest::newRow("dir: +X+Y+Z, up: -X-Y-Z") << QVector3D(10.0f, 10.0f, 10.0f) << QVector3D(-10.0f, -10.0f, -10.0f); // invalid up - foreach (const QQuaternion &q, orientations) { + for (QQuaternion q : orientations) { QVector3D xAxis, yAxis, zAxis; q.getAxes(&xAxis, &yAxis, &zAxis);