Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | // | |||
2 | // Created by kifir on 12/17/24. | |||
3 | // | |||
4 | ||||
5 | #include "pch.h" | |||
6 | ||||
7 | #include "shift_torque_reduction_switch_test_base.h" | |||
8 | ||||
9 | namespace { | |||
10 | class ShiftTorqueReductionSwitchTest : public ShiftTorqueReductionSwitchTestBase { | |||
11 | protected: | |||
12 | void checkThatOtherPinsAreIgnored(TestSwitchPin exceptPin, const std::string& context); | |||
13 | }; | |||
14 | ||||
15 | 34 | void ShiftTorqueReductionSwitchTest::checkThatOtherPinsAreIgnored( | ||
16 | const TestSwitchPin exceptPin, | |||
17 | const std::string& context | |||
18 | ) { | |||
19 | static const TestSwitchPin testInputPins[] = { | |||
20 | TestSwitchPin::TORQUE_REDUCTION, | |||
21 | TestSwitchPin::LUA_TORQUE_REDUCTION, | |||
22 | TestSwitchPin::LAUNCH, | |||
23 | TestSwitchPin::CLUTCH_DOWN, | |||
24 | TestSwitchPin::LUA_CLUTCH_DOWN, | |||
25 | TestSwitchPin::CLUTCH_UP, | |||
26 | TestSwitchPin::LUA_CLUTCH_UP, | |||
27 | }; | |||
28 | 34 | const bool expectedIsTorqueReductionTriggerPinValid = | ||
29 | 34 | engine->shiftTorqueReductionController.isTorqueReductionTriggerPinValid; | ||
30 | 34 | const bool expectedTorqueReductionTriggerPinState = | ||
31 | 34 | engine->shiftTorqueReductionController.torqueReductionTriggerPinState; | ||
32 |
2/2✓ Branch 0 taken 238 times.
✓ Branch 1 taken 34 times.
|
2/2✓ Decision 'true' taken 238 times.
✓ Decision 'false' taken 34 times.
|
272 | for (const TestSwitchPin& pin: testInputPins) { |
33 |
2/2✓ Branch 0 taken 204 times.
✓ Branch 1 taken 34 times.
|
2/2✓ Decision 'true' taken 204 times.
✓ Decision 'false' taken 34 times.
|
238 | if (pin != exceptPin) { |
34 | 204 | setPinState(pin, true); | ||
35 | 204 | checkShiftTorqueReductionState( | ||
36 | context.c_str(), | |||
37 | expectedIsTorqueReductionTriggerPinValid, | |||
38 | expectedTorqueReductionTriggerPinState | |||
39 | ); | |||
40 | ||||
41 | 204 | setPinState(pin, false); | ||
42 | 204 | checkShiftTorqueReductionState( | ||
43 | context.c_str(), | |||
44 | expectedIsTorqueReductionTriggerPinValid, | |||
45 | expectedTorqueReductionTriggerPinState | |||
46 | ); | |||
47 | } | |||
48 | } | |||
49 | 34 | } | ||
50 | ||||
51 |
6/8✓ Branch 6 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
✓ Branch 21 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 29 taken 1 time.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
|
41 | TEST_P(ShiftTorqueReductionSwitchTest, checkTorqueReductionTriggerPinSwitch) { | |
52 | 17 | setUpEngineConfiguration(GetParam().config); | ||
53 | ||||
54 | 17 | const bool expectedIsTorqueReductionTriggerPinValid = GetParam().expectedIsTorqueReductionTriggerPinValid; | ||
55 | ||||
56 | 17 | checkShiftTorqueReductionState("default", expectedIsTorqueReductionTriggerPinValid, false); | ||
57 | ||||
58 | 17 | const TestSwitchPin inputPin = GetParam().inputPin; | ||
59 | 17 | setPinState(inputPin, true); | ||
60 | 17 | checkShiftTorqueReductionState( | ||
61 | "Torque reduction trigger pin is on", | |||
62 | expectedIsTorqueReductionTriggerPinValid, | |||
63 | true | |||
64 | ); | |||
65 |
2/2✓ Branch 3 taken 17 times.
✓ Branch 6 taken 17 times.
|
51 | checkThatOtherPinsAreIgnored(inputPin, "Other pins are ignored when torque reduction trigger pin is on"); | |
66 | ||||
67 | 17 | setPinState(GetParam().inputPin, false); | ||
68 | 17 | checkShiftTorqueReductionState( | ||
69 | "Torque reduction trigger pin is off", | |||
70 | expectedIsTorqueReductionTriggerPinValid, | |||
71 | false | |||
72 | ); | |||
73 |
2/2✓ Branch 3 taken 17 times.
✓ Branch 6 taken 17 times.
|
51 | checkThatOtherPinsAreIgnored(inputPin, "Other pins are ignored when torque reduction trigger pin is off"); | |
74 | 17 | } | ||
75 | ||||
76 |
73/146(anonymous namespace)::gtest_ShiftTorqueReductionSwitchTestForVariousInputPinsShiftTorqueReductionSwitchTest_EvalGenerateName_(testing::TestParamInfo<ShiftTorqueReductionSwitchParams> const&):
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 11 not taken.
✗ Branch 17 not taken.
✗ Branch 23 not taken.
✗ Branch 29 not taken.
✗ Branch 33 not taken.
✗ Branch 40 not taken.
✗ Branch 46 not taken.
✗ Branch 52 not taken.
✗ Branch 58 not taken.
✗ Branch 62 not taken.
✗ Branch 68 not taken.
✗ Branch 74 not taken.
✗ Branch 80 not taken.
✗ Branch 84 not taken.
✗ Branch 90 not taken.
✗ Branch 96 not taken.
✗ Branch 102 not taken.
✗ Branch 106 not taken.
✗ Branch 111 not taken.
✗ Branch 117 not taken.
✗ Branch 121 not taken.
✗ Branch 128 not taken.
✗ Branch 134 not taken.
✗ Branch 140 not taken.
✗ Branch 146 not taken.
✗ Branch 150 not taken.
✗ Branch 157 not taken.
✗ Branch 163 not taken.
✗ Branch 169 not taken.
✗ Branch 175 not taken.
✗ Branch 179 not taken.
✗ Branch 185 not taken.
✗ Branch 191 not taken.
✗ Branch 197 not taken.
✗ Branch 201 not taken.
✗ Branch 207 not taken.
✗ Branch 213 not taken.
✗ Branch 219 not taken.
✗ Branch 223 not taken.
✗ Branch 228 not taken.
✗ Branch 234 not taken.
✗ Branch 238 not taken.
✗ Branch 244 not taken.
✗ Branch 250 not taken.
✗ Branch 256 not taken.
✗ Branch 260 not taken.
✗ Branch 265 not taken.
✗ Branch 271 not taken.
✗ Branch 275 not taken.
✗ Branch 282 not taken.
✗ Branch 288 not taken.
✗ Branch 294 not taken.
✗ Branch 300 not taken.
✗ Branch 304 not taken.
✗ Branch 311 not taken.
✗ Branch 317 not taken.
✗ Branch 323 not taken.
✗ Branch 329 not taken.
✗ Branch 333 not taken.
✗ Branch 339 not taken.
✗ Branch 345 not taken.
✗ Branch 351 not taken.
✗ Branch 355 not taken.
✗ Branch 361 not taken.
✗ Branch 367 not taken.
✗ Branch 373 not taken.
✗ Branch 377 not taken.
✗ Branch 382 not taken.
✗ Branch 388 not taken.
✗ Branch 392 not taken.
✗ Branch 395 not taken.
✗ Branch 398 not taken.
(anonymous namespace)::gtest_ShiftTorqueReductionSwitchTestForVariousInputPinsShiftTorqueReductionSwitchTest_EvalGenerator_():
✓ Branch 6 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 18 taken 1 time.
✓ Branch 24 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 35 taken 1 time.
✓ Branch 41 taken 1 time.
✓ Branch 47 taken 1 time.
✓ Branch 53 taken 1 time.
✓ Branch 57 taken 1 time.
✓ Branch 63 taken 1 time.
✓ Branch 69 taken 1 time.
✓ Branch 75 taken 1 time.
✓ Branch 79 taken 1 time.
✓ Branch 85 taken 1 time.
✓ Branch 91 taken 1 time.
✓ Branch 97 taken 1 time.
✓ Branch 101 taken 1 time.
✓ Branch 106 taken 1 time.
✓ Branch 112 taken 1 time.
✓ Branch 116 taken 1 time.
✓ Branch 123 taken 1 time.
✓ Branch 129 taken 1 time.
✓ Branch 135 taken 1 time.
✓ Branch 141 taken 1 time.
✓ Branch 145 taken 1 time.
✓ Branch 152 taken 1 time.
✓ Branch 158 taken 1 time.
✓ Branch 164 taken 1 time.
✓ Branch 170 taken 1 time.
✓ Branch 174 taken 1 time.
✓ Branch 180 taken 1 time.
✓ Branch 186 taken 1 time.
✓ Branch 192 taken 1 time.
✓ Branch 196 taken 1 time.
✓ Branch 202 taken 1 time.
✓ Branch 208 taken 1 time.
✓ Branch 214 taken 1 time.
✓ Branch 218 taken 1 time.
✓ Branch 223 taken 1 time.
✓ Branch 229 taken 1 time.
✓ Branch 233 taken 1 time.
✓ Branch 239 taken 1 time.
✓ Branch 245 taken 1 time.
✓ Branch 251 taken 1 time.
✓ Branch 255 taken 1 time.
✓ Branch 260 taken 1 time.
✓ Branch 266 taken 1 time.
✓ Branch 270 taken 1 time.
✓ Branch 277 taken 1 time.
✓ Branch 283 taken 1 time.
✓ Branch 289 taken 1 time.
✓ Branch 295 taken 1 time.
✓ Branch 299 taken 1 time.
✓ Branch 306 taken 1 time.
✓ Branch 312 taken 1 time.
✓ Branch 318 taken 1 time.
✓ Branch 324 taken 1 time.
✓ Branch 328 taken 1 time.
✓ Branch 334 taken 1 time.
✓ Branch 340 taken 1 time.
✓ Branch 346 taken 1 time.
✓ Branch 350 taken 1 time.
✓ Branch 356 taken 1 time.
✓ Branch 362 taken 1 time.
✓ Branch 368 taken 1 time.
✓ Branch 372 taken 1 time.
✓ Branch 377 taken 1 time.
✓ Branch 383 taken 1 time.
✓ Branch 387 taken 1 time.
✓ Branch 390 taken 1 time.
✓ Branch 393 taken 1 time.
|
53 | INSTANTIATE_TEST_SUITE_P( | |
77 | ShiftTorqueReductionSwitchTestForVariousInputPins, | |||
78 | ShiftTorqueReductionSwitchTest, | |||
79 | testing::Values( | |||
80 | ShiftTorqueReductionSwitchParams { | |||
81 | /* inputPin = */ TestSwitchPin::TORQUE_REDUCTION, | |||
82 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
83 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON), | |||
84 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
85 | /* description = */ "TORQUE_REDUCTION" | |||
86 | }, | |||
87 | ShiftTorqueReductionSwitchParams { | |||
88 | /* inputPin = */ TestSwitchPin::TORQUE_REDUCTION, | |||
89 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
90 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) | |||
91 | .setTorqueReductionTriggerPinMode(PI_DEFAULT), | |||
92 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
93 | /* description = */ "TORQUE_REDUCTION (pinMode = PI_DEFAULT)" | |||
94 | }, | |||
95 | ShiftTorqueReductionSwitchParams { | |||
96 | /* inputPin = */ TestSwitchPin::LUA_TORQUE_REDUCTION, | |||
97 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
98 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) | |||
99 | .setTorqueReductionTriggerPin(Gpio::Unassigned), | |||
100 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
101 | /* description = */ "LUA_TORQUE_REDUCTION" | |||
102 | }, | |||
103 | ShiftTorqueReductionSwitchParams { | |||
104 | /* inputPin = */ TestSwitchPin::LUA_TORQUE_REDUCTION, | |||
105 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
106 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) | |||
107 | .setTorqueReductionTriggerPin(Gpio::Unassigned) | |||
108 | .setTorqueReductionTriggerPinMode(PI_DEFAULT), | |||
109 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
110 | /* description = */ "LUA_TORQUE_REDUCTION (pinMode = PI_DEFAULT)" | |||
111 | }, | |||
112 | ShiftTorqueReductionSwitchParams { | |||
113 | /* inputPin = */ TestSwitchPin::LUA_TORQUE_REDUCTION, | |||
114 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
115 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_BUTTON) | |||
116 | .setTorqueReductionTriggerPin(Gpio::Unassigned) | |||
117 | .setTorqueReductionTriggerPinMode(PI_INVERTED_DEFAULT), | |||
118 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
119 | /* description = */ "LUA_TORQUE_REDUCTION (pinMode = PI_INVERTED_DEFAULT)" | |||
120 | }, | |||
121 | ShiftTorqueReductionSwitchParams { | |||
122 | /* inputPin = */ TestSwitchPin::LAUNCH, | |||
123 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
124 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::LAUNCH_BUTTON), | |||
125 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
126 | /* description = */ "LAUNCH" | |||
127 | }, | |||
128 | ShiftTorqueReductionSwitchParams { | |||
129 | /* inputPin = */ TestSwitchPin::LAUNCH, | |||
130 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
131 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::LAUNCH_BUTTON) | |||
132 | .setLaunchActivatePinMode(PI_DEFAULT), | |||
133 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
134 | /* description = */ "LAUNCH (pinMode = PI_DEFAULT)" | |||
135 | }, | |||
136 | ShiftTorqueReductionSwitchParams { | |||
137 | /* inputPin = */ TestSwitchPin::CLUTCH_DOWN, | |||
138 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
139 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH), | |||
140 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
141 | /* description = */ "CLUTCH_DOWN" | |||
142 | }, | |||
143 | ShiftTorqueReductionSwitchParams { | |||
144 | /* inputPin = */ TestSwitchPin::CLUTCH_DOWN, | |||
145 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
146 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH) | |||
147 | .setClutchDownPinMode(PI_DEFAULT), | |||
148 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
149 | /* description = */ "CLUTCH_DOWN (pinMode = PI_DEFAULT)" | |||
150 | }, | |||
151 | ShiftTorqueReductionSwitchParams { | |||
152 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_DOWN, | |||
153 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
154 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH) | |||
155 | .setClutchDownPin(Gpio::Unassigned), | |||
156 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
157 | /* description = */ "LUA_CLUTCH_DOWN" | |||
158 | }, | |||
159 | ShiftTorqueReductionSwitchParams { | |||
160 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_DOWN, | |||
161 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
162 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH) | |||
163 | .setClutchDownPin(Gpio::Unassigned) | |||
164 | .setClutchDownPinMode(PI_DEFAULT), | |||
165 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
166 | /* description = */ "LUA_CLUTCH_DOWN (pinMode = PI_DEFAULT)" | |||
167 | }, | |||
168 | ShiftTorqueReductionSwitchParams { | |||
169 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_DOWN, | |||
170 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
171 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_DOWN_SWITCH) | |||
172 | .setClutchDownPin(Gpio::Unassigned) | |||
173 | .setClutchDownPinMode(PI_INVERTED_DEFAULT), | |||
174 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
175 | /* description = */ "LUA_CLUTCH_DOWN (pinMode = PI_INVERTED_DEFAULT)" | |||
176 | }, | |||
177 | ShiftTorqueReductionSwitchParams { | |||
178 | /* inputPin = */ TestSwitchPin::CLUTCH_UP, | |||
179 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
180 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH), | |||
181 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
182 | /* description = */ "CLUTCH_UP" | |||
183 | }, | |||
184 | ShiftTorqueReductionSwitchParams { | |||
185 | /* inputPin = */ TestSwitchPin::CLUTCH_UP, | |||
186 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
187 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH) | |||
188 | .setClutchUpPinMode(PI_DEFAULT), | |||
189 | /* expectedIsTorqueReductionTriggerPinValid = */ true, | |||
190 | /* description = */ "CLUTCH_UP (pinMode = PI_DEFAULT)" | |||
191 | }, | |||
192 | ShiftTorqueReductionSwitchParams { | |||
193 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP, | |||
194 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
195 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH) | |||
196 | .setClutchUpPin(Gpio::Unassigned), | |||
197 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
198 | /* description = */ "LUA_CLUTCH_UP" | |||
199 | }, | |||
200 | ShiftTorqueReductionSwitchParams { | |||
201 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP, | |||
202 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
203 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH) | |||
204 | .setClutchUpPin(Gpio::Unassigned) | |||
205 | .setClutchUpPinMode(PI_DEFAULT), | |||
206 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
207 | /* description = */ "LUA_CLUTCH_UP (pinMode = PI_DEFAULT)" | |||
208 | }, | |||
209 | ShiftTorqueReductionSwitchParams { | |||
210 | /* inputPin = */ TestSwitchPin::LUA_CLUTCH_UP, | |||
211 | /* config = */ ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG.clone() | |||
212 | .setTorqueReductionActivationMode(torqueReductionActivationMode_e::TORQUE_REDUCTION_CLUTCH_UP_SWITCH) | |||
213 | .setClutchUpPin(Gpio::Unassigned) | |||
214 | .setClutchUpPinMode(PI_INVERTED_DEFAULT), | |||
215 | /* expectedIsTorqueReductionTriggerPinValid = */ false, | |||
216 | /* description = */ "LUA_CLUTCH_UP (pinMode = PI_INVERTED_DEFAULT)" | |||
217 | } | |||
218 | ) | |||
219 | ); | |||
220 | } | |||
221 |