mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Fix unit test compile issues
This commit is contained in:
parent
e81d2809c1
commit
1aba6e8fe1
3 changed files with 58 additions and 62 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <QtCore/QFileInfo>
|
||||
#include <functional>
|
||||
#include <NumericalConstants.h>
|
||||
#include <SharedUtil.h>
|
||||
#include "GLMTestUtils.h"
|
||||
|
||||
// Implements several extensions to QtTest.
|
||||
|
@ -37,7 +38,6 @@
|
|||
// from scratch using QTest::qFail, for example).
|
||||
//
|
||||
|
||||
|
||||
float getErrorDifference(const float& a, const float& b) {
|
||||
return fabsf(a - b);
|
||||
}
|
||||
|
@ -265,7 +265,6 @@ do { \
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
struct ByteData {
|
||||
ByteData (const char* data, size_t length)
|
||||
: data(data), length(length) {}
|
||||
|
@ -287,7 +286,6 @@ bool compareData (const char* data, const char* expectedData, size_t length) {
|
|||
#define COMPARE_DATA(actual, expected, length) \
|
||||
QCOMPARE_WITH_EXPR((ByteData(actual, length)), (ByteData(expected, length)), compareData(actual, expected, length))
|
||||
|
||||
|
||||
// Produces a relative error test for float usable QCOMPARE_WITH_LAMBDA.
|
||||
inline auto errorTest (float actual, float expected, float acceptableRelativeError)
|
||||
-> std::function<bool ()> {
|
||||
|
@ -302,8 +300,6 @@ inline auto errorTest (float actual, float expected, float acceptableRelativeErr
|
|||
#define QCOMPARE_WITH_RELATIVE_ERROR(actual, expected, relativeError) \
|
||||
QCOMPARE_WITH_LAMBDA(actual, expected, errorTest(actual, expected, relativeError))
|
||||
|
||||
|
||||
|
||||
inline QString getTestResource(const QString& relativePath) {
|
||||
static QDir dir;
|
||||
static std::once_flag once;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
QTEST_MAIN(AnimTests)
|
||||
|
||||
const float EPSILON = 0.001f;
|
||||
const float TEST_EPSILON = 0.001f;
|
||||
|
||||
void AnimTests::initTestCase() {
|
||||
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||
|
@ -86,12 +86,12 @@ void AnimTests::testClipEvaulate() {
|
|||
|
||||
AnimNode::Triggers triggers;
|
||||
clip.evaluate(vars, context, framesToSec(10.0f), triggers);
|
||||
QCOMPARE_WITH_ABS_ERROR(clip._frame, 12.0f, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(clip._frame, 12.0f, TEST_EPSILON);
|
||||
|
||||
// does it loop?
|
||||
triggers.clear();
|
||||
clip.evaluate(vars, context, framesToSec(12.0f), triggers);
|
||||
QCOMPARE_WITH_ABS_ERROR(clip._frame, 3.0f, EPSILON); // Note: frame 3 and not 4, because extra frame between start and end.
|
||||
QCOMPARE_WITH_ABS_ERROR(clip._frame, 3.0f, TEST_EPSILON); // Note: frame 3 and not 4, because extra frame between start and end.
|
||||
|
||||
// did we receive a loop trigger?
|
||||
QVERIFY(std::find(triggers.begin(), triggers.end(), "myClipNodeOnLoop") != triggers.end());
|
||||
|
@ -100,7 +100,7 @@ void AnimTests::testClipEvaulate() {
|
|||
triggers.clear();
|
||||
clip.setLoopFlagVar("FalseVar");
|
||||
clip.evaluate(vars, context, framesToSec(20.0f), triggers);
|
||||
QCOMPARE_WITH_ABS_ERROR(clip._frame, 22.0f, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(clip._frame, 22.0f, TEST_EPSILON);
|
||||
|
||||
// did we receive a done trigger?
|
||||
QVERIFY(std::find(triggers.begin(), triggers.end(), "myClipNodeOnDone") != triggers.end());
|
||||
|
@ -402,7 +402,7 @@ void AnimTests::testAnimPose() {
|
|||
glm::vec3(10.0f, 5.0f, -7.5f)
|
||||
};
|
||||
|
||||
const float EPSILON = 0.001f;
|
||||
const float TEST_EPSILON = 0.001f;
|
||||
|
||||
for (auto& scale : scaleVec) {
|
||||
for (auto& rot : rotVec) {
|
||||
|
@ -417,7 +417,7 @@ void AnimTests::testAnimPose() {
|
|||
AnimPose pose(scale, rot, trans);
|
||||
glm::mat4 poseMat = pose;
|
||||
|
||||
QCOMPARE_WITH_ABS_ERROR(rawMat, poseMat, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(rawMat, poseMat, TEST_EPSILON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ void AnimTests::testAnimPose() {
|
|||
// now build a new matrix from those parts.
|
||||
glm::mat4 poseMat = pose;
|
||||
|
||||
QCOMPARE_WITH_ABS_ERROR(rawMat, poseMat, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(rawMat, poseMat, TEST_EPSILON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ const quat rot90 = glm::angleAxis((float)M_PI / 2.0f, yAxis);
|
|||
|
||||
QTEST_MAIN(TransformTests)
|
||||
|
||||
const float EPSILON = 0.001f;
|
||||
const float TEST_EPSILON = 0.001f;
|
||||
|
||||
void TransformTests::getMatrix() {
|
||||
|
||||
|
@ -55,7 +55,7 @@ void TransformTests::getMatrix() {
|
|||
mat4 result_b;
|
||||
xform.getMatrix(result_b);
|
||||
|
||||
QCOMPARE_WITH_ABS_ERROR(result_a, result_b, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(result_a, result_b, TEST_EPSILON);
|
||||
}
|
||||
|
||||
void TransformTests::getInverseMatrix() {
|
||||
|
@ -92,7 +92,7 @@ void TransformTests::getInverseMatrix() {
|
|||
auto yb = transformPoint(result_b, yAxis);
|
||||
auto zb = transformPoint(result_b, zAxis);
|
||||
|
||||
QCOMPARE_WITH_ABS_ERROR(xa, xb, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(ya, yb, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(za, zb, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(xa, xb, TEST_EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(ya, yb, TEST_EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR(za, zb, TEST_EPSILON);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue