new geo functions

changed the walkers
added moving average
fixed the interpolator
new test-cases
This commit is contained in:
2016-01-30 19:49:18 +01:00
parent da0bd43fe0
commit ec86b07c43
8 changed files with 185 additions and 15 deletions

View File

@@ -0,0 +1,40 @@
#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