rusefi-1/unit_tests/tests/test_ion.cpp

44 lines
731 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
* @author Andrey Belomutskiy, (c) 2012-2019
2019-01-04 20:47:39 -08:00
*/
#ifndef TEST_ION_CPP_
#define TEST_ION_CPP_
#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
state.onNewSignal(2);
state.onNewSignal(2);
state.onNewSignal(2);
// value is still '0' until we signal end of engine cycle
2019-05-05 15:53:34 -07:00
EXPECT_EQ(0, state.getValue(2));
// this invocation would flush current accumulation
EXPECT_EQ(3, state.getValue(3));
state.onNewSignal(3);
// returning previous full cycle value
EXPECT_EQ(3, state.getValue(3));
EXPECT_EQ(1, state.getValue(4));
EXPECT_EQ(0, state.getValue(5));
2019-01-04 20:47:39 -08:00
}
#endif /* TEST_ION_CPP_ */