rusefi-1/unit_tests/tests/test_ion.cpp

35 lines
849 B
C++
Raw Normal View History

2019-01-04 20:47:39 -08:00
/*
2019-11-17 06:03:20 -08:00
* @file test_ion.cpp
2019-01-04 20:47:39 -08:00
*
2019-11-17 06:03:20 -08:00
* @date Jan 4, 2019
2020-01-07 21:02:40 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2019-01-04 20:47:39 -08:00
*/
#include "gtest/gtest.h"
#include "cdm_ion_sense.h"
TEST(ion, signalCounter) {
CdmState state;
2019-05-05 15:53:34 -07:00
EXPECT_EQ(0, state.getValue(0));
2019-01-04 20:47:39 -08:00
2019-12-09 22:03:02 -08:00
state.onNewSignal(/* currentRevolution= */ 2);
state.onNewSignal(/* currentRevolution= */ 2);
state.onNewSignal(/* currentRevolution= */ 2);
2019-01-04 20:47:39 -08:00
// value is still '0' until we signal end of engine cycle
2019-12-09 22:03:02 -08:00
EXPECT_EQ(0, state.getValue(/* currentRevolution= */2));
2019-05-05 15:53:34 -07:00
// this invocation would flush current accumulation
2019-12-09 22:03:02 -08:00
EXPECT_EQ(3, state.getValue(/* currentRevolution= */3));
2019-05-05 15:53:34 -07:00
2019-12-09 22:03:02 -08:00
state.onNewSignal(/* currentRevolution= */3);
2019-05-05 15:53:34 -07:00
// returning previous full cycle value
EXPECT_EQ(3, state.getValue(3));
2019-12-09 22:03:02 -08:00
EXPECT_EQ(1, state.getValue(/* currentRevolution= */4));
EXPECT_EQ(0, state.getValue(/* currentRevolution= */5));
2019-01-04 20:47:39 -08:00
}