Added regresion test for FrskyValueWithMin averaging algorithm

This commit is contained in:
Damjan Adamic
2014-07-01 15:40:12 +02:00
parent 74dfd64e29
commit 74f4f99280
+30
View File
@@ -334,6 +334,36 @@ TEST(FrSkySPORT, checkCrc)
}
#endif
#if defined(FRSKY) && defined(CPUARM)
TEST(FrSky, FrskyValueWithMinAveraging)
{
/*
The following expected[] array is filled
with values that correspond to 4 elements
long averaging buffer.
If length of averaging buffer is changed, this
values must be adjusted
*/
uint8_t expected[] = { 10, 12, 17, 25, 35, 45, 55, 65, 75, 85, 92, 97, 100, 100, 100, 100, 100};
int testPos = 0;
//test of averaging
FrskyValueWithMin testVal;
testVal.value = 0;
testVal.set(10);
EXPECT_EQ(testVal.value, expected[testPos++]);
for(int n=2; n<10; ++n) {
testVal.set(n*10);
EXPECT_EQ(testVal.value, expected[testPos++]);
}
for(int n=2; n<10; ++n) {
testVal.set(100);
EXPECT_EQ(testVal.value, expected[testPos++]);
}
}
#endif
#if !defined(PCBTARANIS)
TEST(getSwitch, undefCSW)
{