tst_QQuaternion: compile with QT_NO_FOREACH
The size of the container is fixed, so use std::array. QQuaternion is basically four floats, so make the range-for var a value rather than a reference. Task-number: QTBUG-115839 Change-Id: I50b5aaa7daa6a4f10ff55c55ae54259c9aea03e9 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
a13bfec63d
commit
3928d53003
@ -1,8 +1,6 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
// 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 <QTest>
|
||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
#include <QtGui/qquaternion.h>
|
#include <QtGui/qquaternion.h>
|
||||||
@ -970,19 +968,23 @@ void tst_QQuaternion::fromDirection_data()
|
|||||||
QTest::addColumn<QVector3D>("direction");
|
QTest::addColumn<QVector3D>("direction");
|
||||||
QTest::addColumn<QVector3D>("up");
|
QTest::addColumn<QVector3D>("up");
|
||||||
|
|
||||||
QList<QQuaternion> orientations;
|
// 1 default constructed element + 360/45 loops, each adding 4 elements
|
||||||
orientations << QQuaternion();
|
constexpr int size = 1 + (360 / 45) * 4;
|
||||||
|
std::array<QQuaternion, size> orientations;
|
||||||
|
orientations[0] = {};
|
||||||
|
int n = 0;
|
||||||
for (int angle = 45; angle <= 360; angle += 45) {
|
for (int angle = 45; angle <= 360; angle += 45) {
|
||||||
orientations << QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), angle)
|
orientations[++n] = QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), angle);
|
||||||
<< QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), angle)
|
orientations[++n] = QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), angle);
|
||||||
<< QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), angle)
|
orientations[++n] = QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), angle);
|
||||||
<< QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), angle)
|
orientations[++n] = QQuaternion::fromAxisAndAngle(QVector3D(1, 0, 0), angle)
|
||||||
* QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), angle)
|
* QQuaternion::fromAxisAndAngle(QVector3D(0, 1, 0), angle)
|
||||||
* QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), angle);
|
* QQuaternion::fromAxisAndAngle(QVector3D(0, 0, 1), angle);
|
||||||
}
|
}
|
||||||
|
QCOMPARE(n, size - 1);
|
||||||
|
|
||||||
// othonormal up and dir
|
// othonormal up and dir
|
||||||
foreach (const QQuaternion &q, orientations) {
|
for (QQuaternion q : orientations) {
|
||||||
QVector3D xAxis, yAxis, zAxis;
|
QVector3D xAxis, yAxis, zAxis;
|
||||||
q.getAxes(&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);
|
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
|
// invalid up
|
||||||
foreach (const QQuaternion &q, orientations) {
|
for (QQuaternion q : orientations) {
|
||||||
QVector3D xAxis, yAxis, zAxis;
|
QVector3D xAxis, yAxis, zAxis;
|
||||||
q.getAxes(&xAxis, &yAxis, &zAxis);
|
q.getAxes(&xAxis, &yAxis, &zAxis);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user