2021-11-24 18:53:32 -08:00
|
|
|
|
|
|
|
|
|
|
|
#include "pch.h"
|
2021-11-24 19:36:36 -08:00
|
|
|
#include "trigger_central.h"
|
2021-11-24 18:53:32 -08:00
|
|
|
|
|
|
|
static int getZigZag(int index) {
|
|
|
|
index = index % 1000;
|
|
|
|
|
|
|
|
if (index < 400) {
|
|
|
|
// going up from 0 to 400
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
if (index < 500) {
|
|
|
|
// going down from 400 to 300
|
|
|
|
return 800 - index;
|
|
|
|
}
|
|
|
|
if (index < 600) {
|
|
|
|
// going up from 300 to 400
|
|
|
|
return index - 200;
|
|
|
|
}
|
|
|
|
// going down from 400 to 0
|
|
|
|
return 1000 - index;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(trigger, map_cam) {
|
2021-12-04 15:20:01 -08:00
|
|
|
EngineTestHelper eth(TEST_ENGINE);
|
2021-11-24 18:53:32 -08:00
|
|
|
|
2021-12-04 15:20:01 -08:00
|
|
|
engineConfiguration->mapCamAveragingLength = 8;
|
2021-11-24 18:53:32 -08:00
|
|
|
MapState state;
|
|
|
|
|
|
|
|
int i = 0;
|
2021-12-05 11:25:13 -08:00
|
|
|
for (;i<403;i++) {
|
2021-11-24 18:53:32 -08:00
|
|
|
state.add(getZigZag(i));
|
|
|
|
|
2021-12-04 15:20:01 -08:00
|
|
|
if (state.mapBuffer.getCount() > engineConfiguration->mapCamAveragingLength) {
|
2021-12-05 11:25:13 -08:00
|
|
|
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
|
|
|
|
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
|
2021-11-24 18:53:32 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
state.add(getZigZag(i));
|
2021-12-05 11:25:13 -08:00
|
|
|
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
|
|
|
|
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
|
|
state.add(getZigZag(i));
|
|
|
|
ASSERT_TRUE(state.isPeak(false)) << "high At " << i;
|
|
|
|
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
|
|
|
|
|
|
|
|
for (;i<504;i++) {
|
|
|
|
state.add(getZigZag(i));
|
|
|
|
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
|
|
|
|
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
|
|
|
|
}
|
|
|
|
|
|
|
|
state.add(getZigZag(i));
|
|
|
|
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
|
|
|
|
ASSERT_TRUE(state.isPeak(true)) << "low At " << i;
|
|
|
|
i++;
|
2021-11-24 18:53:32 -08:00
|
|
|
|
|
|
|
for (;i<604;i++) {
|
|
|
|
state.add(getZigZag(i));
|
2021-12-05 11:25:13 -08:00
|
|
|
ASSERT_FALSE(state.isPeak(false)) << "high At " << i;
|
|
|
|
ASSERT_FALSE(state.isPeak(true)) << "low At " << i;
|
2021-11-24 18:53:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
state.add(getZigZag(i));
|
2021-12-05 11:25:13 -08:00
|
|
|
ASSERT_TRUE(state.isPeak(false)) << "high At " << i;
|
|
|
|
ASSERT_TRUE(state.isPeak(false)) << "low At " << i;
|
2021-11-24 18:53:32 -08:00
|
|
|
}
|