28static CommonSmoothedValueTests <SmoothedValue<float, ValueSmoothingTypes::Linear>> commonLinearSmoothedValueTests;
29static CommonSmoothedValueTests <SmoothedValue<float, ValueSmoothingTypes::Multiplicative>> commonMultiplicativeSmoothedValueTests;
31class SmoothedValueTests :
public UnitTest
35 : UnitTest (
"SmoothedValueTests", UnitTestCategories::smoothedValues)
38 void runTest()
override
40 beginTest (
"Linear moving target");
47 sv.setTargetValue (1.0f);
60 beginTest (
"Multiplicative curve");
67 sv.reset (numSamples);
68 sv.setCurrentAndTargetValue (1.0);
69 sv.setTargetValue (2.0f);
71 values.setSample (0, 0,
sv.getCurrentValue());
73 for (
int i = 1; i < values.getNumSamples(); ++i)
74 values.setSample (0, i,
sv.getNextValue());
76 sv.setTargetValue (1.0f);
77 values.setSample (1, values.getNumSamples() - 1,
sv.getCurrentValue());
79 for (
int i = values.getNumSamples() - 2; i >= 0 ; --i)
80 values.setSample (1, i,
sv.getNextValue());
82 for (
int i = 0; i < values.getNumSamples(); ++i)
83 expectWithinAbsoluteError (values.getSample (0, i), values.getSample (1, i), 1.0e-9);
88static SmoothedValueTests smoothedValueTests;