This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/tests/math/TestInterpolator.cpp
FrankE ec86b07c43 new geo functions
changed the walkers
added moving average
fixed the interpolator
new test-cases
2016-01-30 19:49:18 +01:00

41 lines
932 B
C++

#ifdef WITH_TESTS
#include "../Tests.h"
#include "../../math/Interpolator.h"
TEST(Interpolator, addAndGet) {
Interpolator<int, float> interp;
interp.add(10, 20);
interp.add(20, 30);
interp.add(30, 50);
ASSERT_EQ(20, std::round(interp.get(0))); // before
ASSERT_EQ(20, std::round(interp.get(10))); // matches
ASSERT_EQ(21, std::round(interp.get(11)));
ASSERT_EQ(25, std::round(interp.get(15)));
ASSERT_EQ(29, std::round(interp.get(19)));
ASSERT_EQ(30, std::round(interp.get(20))); //matches
ASSERT_EQ(40, std::round(interp.get(25)));
ASSERT_EQ(42, std::round(interp.get(26)));
ASSERT_EQ(50, std::round(interp.get(30))); // matches
ASSERT_EQ(50, std::round(interp.get(99))); // after
}
TEST(Interpolator, sanity) {
Interpolator<int, int> interp;
interp.add(10, 20);
ASSERT_THROW( interp.add(10,30), std::exception );
interp.add(12, 22);
ASSERT_THROW( interp.add(11,21), std::exception );
}
#endif