forked from rusefi/rusefi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_ion.cpp
34 lines (24 loc) · 849 Bytes
/
test_ion.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* @file test_ion.cpp
*
* @date Jan 4, 2019
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "gtest/gtest.h"
#include "cdm_ion_sense.h"
TEST(ion, signalCounter) {
CdmState state;
EXPECT_EQ(0, state.getValue(0));
state.onNewSignal(/* currentRevolution= */ 2);
state.onNewSignal(/* currentRevolution= */ 2);
state.onNewSignal(/* currentRevolution= */ 2);
// value is still '0' until we signal end of engine cycle
EXPECT_EQ(0, state.getValue(/* currentRevolution= */2));
// this invocation would flush current accumulation
EXPECT_EQ(3, state.getValue(/* currentRevolution= */3));
state.onNewSignal(/* currentRevolution= */3);
// returning previous full cycle value
EXPECT_EQ(3, state.getValue(3));
EXPECT_EQ(1, state.getValue(/* currentRevolution= */4));
EXPECT_EQ(0, state.getValue(/* currentRevolution= */5));
}