Browse Source

Animation: be less strict about bounds for double easings.

Happens only in release builds. Interesting.
pull/601/head
Vladimír Vondruš 3 years ago
parent
commit
32398ffadd
  1. 16
      src/Magnum/Animation/Test/EasingTest.cpp

16
src/Magnum/Animation/Test/EasingTest.cpp

@ -257,6 +257,18 @@ EasingTest::EasingTest() {
enum: std::size_t { PropertyVerificationStepCount = 50 };
template<class> struct BoundsLimits;
template<> struct BoundsLimits<Float> {
static Float min() { return 0.0f; }
static Float max() { return 1.0f; }
};
template<> struct BoundsLimits<Double> {
/* Doubles very slightly overflow the bounds in release builds for some
of the functions, have some epsilon there */
static Double min() { return 0.0 - Math::TypeTraits<Double>::epsilon(); }
static Double max() { return 1.0 + Math::TypeTraits<Double>::epsilon(); }
};
template<class T> void EasingTest::bounds() {
auto&& data = BoundsData[testCaseInstanceId()];
setTestCaseDescription(data.name);
@ -265,8 +277,8 @@ template<class T> void EasingTest::bounds() {
T scale = T(1.0)/T(PropertyVerificationStepCount - 1);
for(std::size_t i = 0; i != PropertyVerificationStepCount; ++i) {
T t = i*scale;
CORRADE_COMPARE_AS(FunctionFor<T>::function(data)(t), T(0.0), TestSuite::Compare::GreaterOrEqual);
CORRADE_COMPARE_AS(FunctionFor<T>::function(data)(t), T(1.0), TestSuite::Compare::LessOrEqual);
CORRADE_COMPARE_AS(FunctionFor<T>::function(data)(t), BoundsLimits<T>::min(), TestSuite::Compare::GreaterOrEqual);
CORRADE_COMPARE_AS(FunctionFor<T>::function(data)(t), BoundsLimits<T>::max(), TestSuite::Compare::LessOrEqual);
}
}

Loading…
Cancel
Save