mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-08 00:22:25 +02:00
Fixes
This commit is contained in:
parent
b47cb76e3c
commit
8e324f5de2
4 changed files with 35 additions and 39 deletions
|
@ -160,7 +160,7 @@ inline void QTest_failWithMessage(
|
|||
template <typename T, typename V>
|
||||
inline bool QTest_compareWithAbsError(const T & actual, const T & expected, const char * actual_expr, const char * expected_expr, int line, const char * file, const V & epsilon)
|
||||
{
|
||||
if (getErrorDifference(actual, expected) > epsilon) {
|
||||
if (abs(getErrorDifference(actual, expected)) > abs(epsilon)) {
|
||||
QTest_failWithMessage(
|
||||
"Compared values are not the same (fuzzy compare)",
|
||||
actual, expected, actual_expr, expected_expr, line, file,
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// BulletTestUtils.h
|
||||
// hifi
|
||||
// tests/physics/src
|
||||
//
|
||||
// Created by Seiji Emery on 6/22/15.
|
||||
// Created by Seiji Emery on 6/22/15
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_BulletTestUtils_h
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
//
|
||||
// GlmTestUtils.h
|
||||
// hifi
|
||||
// tests/physics/src
|
||||
//
|
||||
// Created by Seiji Emery on 6/22/15.
|
||||
// Created by Seiji Emery on 6/22/15
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_GlmTestUtils_h
|
||||
|
|
|
@ -67,34 +67,25 @@ void MovingMinMaxAvgTests::testQuint64() {
|
|||
QCOMPARE_WITH_ABS_ERROR((float) stats.getAverage() / (float) average, 1.0f, EPSILON);
|
||||
QCOMPARE_WITH_ABS_ERROR((float) stats.getAverage(), (float) average, EPSILON);
|
||||
|
||||
// QCOMPARE(fabsf(
|
||||
// (float)stats.getAverage() / (float)average - 1.0f
|
||||
// ) < EPSILON ||
|
||||
// fabsf(
|
||||
// (float)stats.getAverage() - (float)average) < EPSILON);
|
||||
|
||||
if ((i + 1) % INTERVAL_LENGTH == 0) {
|
||||
|
||||
assert(stats.getNewStatsAvailableFlag());
|
||||
QVERIFY(stats.getNewStatsAvailableFlag());
|
||||
stats.clearNewStatsAvailableFlag();
|
||||
|
||||
windowMin = std::numeric_limits<quint64>::max();
|
||||
windowMax = 0;
|
||||
windowAverage = 0.0;
|
||||
foreach(quint64 s, windowSamples) {
|
||||
for (quint64 s : windowSamples) {
|
||||
windowMin = std::min(windowMin, s);
|
||||
windowMax = std::max(windowMax, s);
|
||||
windowAverage += (double)s;
|
||||
}
|
||||
windowAverage /= (double)windowSamples.size();
|
||||
|
||||
assert(stats.getWindowMin() == windowMin);
|
||||
assert(stats.getWindowMax() == windowMax);
|
||||
assert(fabsf((float)stats.getAverage() / (float)average - 1.0f) < EPSILON ||
|
||||
fabsf((float)stats.getAverage() - (float)average) < EPSILON);
|
||||
|
||||
QCOMPARE(stats.getWindowMin(), windowMin);
|
||||
QCOMPARE(stats.getWindowMax(), windowMax);
|
||||
QCOMPARE_WITH_ABS_ERROR((float)stats.getAverage(), (float)average, EPSILON);
|
||||
} else {
|
||||
assert(!stats.getNewStatsAvailableFlag());
|
||||
QVERIFY(!stats.getNewStatsAvailableFlag());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,31 +125,30 @@ void MovingMinMaxAvgTests::testInt() {
|
|||
average = (average * totalSamples + sample) / (totalSamples + 1);
|
||||
totalSamples++;
|
||||
|
||||
assert(stats.getMin() == min);
|
||||
assert(stats.getMax() == max);
|
||||
assert(fabsf((float)stats.getAverage() / (float)average - 1.0f) < EPSILON);
|
||||
QCOMPARE(stats.getMin(), min);
|
||||
QCOMPARE(stats.getMax(), max);
|
||||
QCOMPARE_WITH_ABS_ERROR((float)stats.getAverage(), (float)average, EPSILON);
|
||||
|
||||
if ((i + 1) % INTERVAL_LENGTH == 0) {
|
||||
|
||||
assert(stats.getNewStatsAvailableFlag());
|
||||
QVERIFY(stats.getNewStatsAvailableFlag());
|
||||
stats.clearNewStatsAvailableFlag();
|
||||
|
||||
windowMin = std::numeric_limits<int>::max();
|
||||
windowMax = 0;
|
||||
windowAverage = 0.0;
|
||||
foreach(int s, windowSamples) {
|
||||
for (int s : windowSamples) {
|
||||
windowMin = std::min(windowMin, s);
|
||||
windowMax = std::max(windowMax, s);
|
||||
windowAverage += (double)s;
|
||||
}
|
||||
windowAverage /= (double)windowSamples.size();
|
||||
|
||||
assert(stats.getWindowMin() == windowMin);
|
||||
assert(stats.getWindowMax() == windowMax);
|
||||
assert(fabsf((float)stats.getAverage() / (float)average - 1.0f) < EPSILON);
|
||||
|
||||
QCOMPARE(stats.getWindowMin(), windowMin);
|
||||
QCOMPARE(stats.getWindowMax(), windowMax);
|
||||
QCOMPARE_WITH_ABS_ERROR((float)stats.getAverage(), (float)average, EPSILON);
|
||||
} else {
|
||||
assert(!stats.getNewStatsAvailableFlag());
|
||||
QVERIFY(!stats.getNewStatsAvailableFlag());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,31 +188,31 @@ void MovingMinMaxAvgTests::testFloat() {
|
|||
average = (average * totalSamples + (double)sample) / (totalSamples + 1);
|
||||
totalSamples++;
|
||||
|
||||
assert(stats.getMin() == min);
|
||||
assert(stats.getMax() == max);
|
||||
assert(fabsf((float)stats.getAverage() / (float)average - 1.0f) < EPSILON);
|
||||
QCOMPARE(stats.getMin(), min);
|
||||
QCOMPARE(stats.getMax(), max);
|
||||
QCOMPARE_WITH_ABS_ERROR((float)stats.getAverage(), (float)average, EPSILON);
|
||||
|
||||
if ((i + 1) % INTERVAL_LENGTH == 0) {
|
||||
|
||||
assert(stats.getNewStatsAvailableFlag());
|
||||
QVERIFY(stats.getNewStatsAvailableFlag());
|
||||
stats.clearNewStatsAvailableFlag();
|
||||
|
||||
windowMin = std::numeric_limits<float>::max();
|
||||
windowMax = 0;
|
||||
windowAverage = 0.0;
|
||||
foreach(float s, windowSamples) {
|
||||
for (float s : windowSamples) {
|
||||
windowMin = std::min(windowMin, s);
|
||||
windowMax = std::max(windowMax, s);
|
||||
windowAverage += (double)s;
|
||||
}
|
||||
windowAverage /= (double)windowSamples.size();
|
||||
|
||||
assert(stats.getWindowMin() == windowMin);
|
||||
assert(stats.getWindowMax() == windowMax);
|
||||
assert(fabsf((float)stats.getAverage() / (float)average - 1.0f) < EPSILON);
|
||||
QCOMPARE(stats.getWindowMin(), windowMin);
|
||||
QCOMPARE(stats.getWindowMax(), windowMax);
|
||||
QCOMPARE_WITH_ABS_ERROR((float)stats.getAverage(), (float)average, EPSILON);
|
||||
|
||||
} else {
|
||||
assert(!stats.getNewStatsAvailableFlag());
|
||||
QVERIFY(!stats.getNewStatsAvailableFlag());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue