Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | // | |||
2 | // Created by kifir on 12/5/24. | |||
3 | // | |||
4 | ||||
5 | #include "pch.h" | |||
6 | ||||
7 | #include "nitrous_test_base.h" | |||
8 | ||||
9 | 11 | void NitrousTestBase::setUpTestConfiguration( | ||
10 | const std::optional<int8_t> nitrousFuelAdderPercent, | |||
11 | const std::optional<float> nitrousIgnitionRetard | |||
12 | ) { | |||
13 |
1/1✓ Branch 2 taken 11 times.
|
33 | setUpEngineConfiguration(EngineConfig() | |
14 |
1/1✓ Branch 6 taken 11 times.
|
33 | .setNitrousControlEnabled({ true }) | |
15 |
1/1✓ Branch 5 taken 11 times.
|
44 | .setNitrousControlArmingMethod({ DIGITAL_SWITCH_INPUT }) | |
16 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousControlTriggerPin({ TEST_NITROUS_CONTROL_ARMING_PIN }) | |
17 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousMinimumVehicleSpeed({ TEST_MIN_VEHICLE_SPEED }) | |
18 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousMinimumTps({ TEST_MIN_TPS }) | |
19 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousMinimumClt({ TEST_MIN_CLT }) | |
20 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousMaximumMap({ TEST_MAX_MAP }) | |
21 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousMaximumAfr({ TEST_MAXIMUM_AFR }) | |
22 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousActivationRpm({ TEST_ACTIVATION_RPM }) | |
23 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousDeactivationRpm({ TEST_DEACTIVATION_RPM }) | |
24 |
1/1✓ Branch 4 taken 11 times.
|
44 | .setNitrousDeactivationRpmWindow({ TEST_DEACTIVATION_RPM_WINDOW }) | |
25 |
1/1✓ Branch 2 taken 11 times.
|
33 | .setNitrousFuelAdderPercent(nitrousFuelAdderPercent) | |
26 |
1/1✓ Branch 2 taken 11 times.
|
33 | .setNitrousIgnitionRetard(nitrousIgnitionRetard) | |
27 | ); | |||
28 | 11 | } | ||
29 | ||||
30 | 11 | void NitrousTestBase::armNitrousControl() { | ||
31 | 11 | setMockState(TEST_NITROUS_CONTROL_ARMING_PIN, true); | ||
32 | 11 | periodicSlowCallback(); | ||
33 | ||||
34 |
2/7✓ Branch 3 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
11 | EXPECT_TRUE(getModule<NitrousController>().isNitrousArmed); | |
35 | 11 | } | ||
36 | ||||
37 | 11 | void NitrousTestBase::satisfySpeedCondition() { | ||
38 |
1/1✓ Branch 3 taken 11 times.
|
11 | updateVehicleSpeed(TEST_MIN_VEHICLE_SPEED, &TestBase::periodicSlowCallback); | |
39 | ||||
40 |
2/7✓ Branch 3 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
11 | EXPECT_TRUE(getModule<NitrousController>().isNitrousSpeedCondition); | |
41 | 11 | } | ||
42 | ||||
43 | 11 | void NitrousTestBase::satisfyTpsCondition() { | ||
44 |
1/1✓ Branch 3 taken 11 times.
|
11 | updateApp(TEST_MIN_TPS, &TestBase::periodicSlowCallback); | |
45 | ||||
46 |
2/7✓ Branch 3 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
11 | EXPECT_TRUE(getModule<NitrousController>().isNitrousTpsCondition); | |
47 | 11 | } | ||
48 | ||||
49 | 11 | void NitrousTestBase::satisfyCltCondition() { | ||
50 |
1/1✓ Branch 3 taken 11 times.
|
11 | updateClt(TEST_MIN_CLT, &TestBase::periodicSlowCallback); | |
51 | ||||
52 |
2/7✓ Branch 3 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
11 | EXPECT_TRUE(getModule<NitrousController>().isNitrousCltCondition); | |
53 | 11 | } | ||
54 | ||||
55 | 11 | void NitrousTestBase::satisfyMapCondition() { | ||
56 |
1/1✓ Branch 3 taken 11 times.
|
11 | updateMap(TEST_MAX_MAP, &TestBase::periodicSlowCallback); | |
57 | ||||
58 |
2/7✓ Branch 3 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
11 | EXPECT_TRUE(getModule<NitrousController>().isNitrousMapCondition); | |
59 | 11 | } | ||
60 | ||||
61 | 11 | void NitrousTestBase::satisfyAfrCondition() { | ||
62 |
1/1✓ Branch 3 taken 11 times.
|
11 | updateLambda1(TEST_LAMBDA1, &TestBase::periodicSlowCallback); | |
63 | ||||
64 |
2/7✓ Branch 3 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
11 | EXPECT_TRUE(getModule<NitrousController>().isNitrousAfrCondition); | |
65 | 11 | } | ||
66 | ||||
67 | 11 | void NitrousTestBase::satisfyRpmCondition() { | ||
68 |
1/1✓ Branch 3 taken 11 times.
|
11 | updateRpm(TEST_ACTIVATION_RPM, &TestBase::periodicSlowCallback); | |
69 | ||||
70 |
2/7✓ Branch 3 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
11 | EXPECT_TRUE(getModule<NitrousController>().isNitrousRpmCondition); | |
71 | 11 | } | ||
72 | ||||
73 | 4 | void NitrousTestBase::activateNitrousControl() { | ||
74 | 4 | armNitrousControl(); | ||
75 | 4 | satisfySpeedCondition(); | ||
76 | 4 | satisfyTpsCondition(); | ||
77 | 4 | satisfyCltCondition(); | ||
78 | 4 | satisfyMapCondition(); | ||
79 | 4 | satisfyAfrCondition(); | ||
80 | 4 | satisfyRpmCondition(); | ||
81 | 4 | } | ||
82 | ||||
83 | 5 | void NitrousTestBase::unarmNitrousControl() { | ||
84 | 5 | setMockState(TEST_NITROUS_CONTROL_ARMING_PIN, false); | ||
85 | 5 | periodicSlowCallback(); | ||
86 | ||||
87 |
2/7✓ Branch 3 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
5 | EXPECT_FALSE(getModule<NitrousController>().isNitrousArmed); | |
88 | 5 | } | ||
89 | ||||
90 | 5 | void NitrousTestBase::unsatisfySpeedCondition() { | ||
91 |
1/1✓ Branch 4 taken 5 times.
|
5 | updateVehicleSpeed(TEST_MIN_VEHICLE_SPEED - EPS5D, &TestBase::periodicSlowCallback); | |
92 | ||||
93 |
2/7✓ Branch 3 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
5 | EXPECT_FALSE(getModule<NitrousController>().isNitrousSpeedCondition); | |
94 | 5 | } | ||
95 | ||||
96 | 5 | void NitrousTestBase::unsatisfyTpsCondition() { | ||
97 |
1/1✓ Branch 4 taken 5 times.
|
5 | updateApp(TEST_MIN_TPS - EPS5D, &TestBase::periodicSlowCallback); | |
98 | ||||
99 |
2/7✓ Branch 3 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
5 | EXPECT_FALSE(getModule<NitrousController>().isNitrousTpsCondition); | |
100 | 5 | } | ||
101 | ||||
102 | 5 | void NitrousTestBase::unsatisfyCltCondition() { | ||
103 |
1/1✓ Branch 4 taken 5 times.
|
5 | updateClt(TEST_MIN_CLT - EPS5D, &TestBase::periodicSlowCallback); | |
104 | ||||
105 |
2/7✓ Branch 3 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
5 | EXPECT_FALSE(getModule<NitrousController>().isNitrousCltCondition); | |
106 | 5 | } | ||
107 | ||||
108 | 5 | void NitrousTestBase::unsatisfyMapCondition() { | ||
109 |
1/1✓ Branch 4 taken 5 times.
|
5 | updateMap(TEST_MAX_MAP + EPS5D, &TestBase::periodicSlowCallback); | |
110 | ||||
111 |
2/7✓ Branch 3 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
5 | EXPECT_FALSE(getModule<NitrousController>().isNitrousMapCondition); | |
112 | 5 | } | ||
113 | ||||
114 | 5 | void NitrousTestBase::unsatisfyAfrCondition() { | ||
115 |
1/1✓ Branch 4 taken 5 times.
|
5 | updateLambda1(TEST_LAMBDA1 + EPS5D, &TestBase::periodicSlowCallback); | |
116 | ||||
117 |
2/7✓ Branch 3 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
5 | EXPECT_FALSE(getModule<NitrousController>().isNitrousAfrCondition); | |
118 | 5 | } | ||
119 | ||||
120 | 5 | void NitrousTestBase::unsatisfyRpmCondition() { | ||
121 |
1/1✓ Branch 4 taken 5 times.
|
5 | updateRpm(TEST_ACTIVATION_RPM - EPS5D, &TestBase::periodicSlowCallback); | |
122 | ||||
123 |
2/7✓ Branch 3 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
5 | EXPECT_FALSE(getModule<NitrousController>().isNitrousRpmCondition); | |
124 | 5 | } | ||
125 | ||||
126 | 4 | void NitrousTestBase::deactivateNitrousControl() { | ||
127 | 4 | unarmNitrousControl(); | ||
128 | 4 | unsatisfySpeedCondition(); | ||
129 | 4 | unsatisfyTpsCondition(); | ||
130 | 4 | unsatisfyCltCondition(); | ||
131 | 4 | unsatisfyMapCondition(); | ||
132 | 4 | unsatisfyAfrCondition(); | ||
133 | 4 | unsatisfyRpmCondition(); | ||
134 | 4 | } | ||
135 | ||||
136 | 66 | void NitrousTestBase::checkNitrousCondition(const bool expected, const char* const context) { | ||
137 |
3/8✓ Branch 3 taken 66 times.
✓ Branch 6 taken 66 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 66 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
|
66 | EXPECT_EQ(getModule<NitrousController>().isNitrousCondition, expected) << context; | |
138 |
3/8✓ Branch 3 taken 66 times.
✓ Branch 6 taken 66 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 66 times.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
|
66 | EXPECT_EQ(enginePins.nitrousRelay.getLogicValue(), expected) << context; | |
139 | 66 | } | ||
140 |