| 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 | const EngineConfig ShiftTorqueReductionSwitchTestBase::TEST_ENGINE_CONFIG = EngineConfig() | |||
| 10 | .setTorqueReductionEnabled(true) | |||
| 11 | .setTorqueReductionTriggerPin(TEST_TORQUE_REDUCTION_BUTTON_PIN) | |||
| 12 | .setLaunchActivatePin(TEST_LAUNCH_BUTTON_PIN) | |||
| 13 | .setClutchDownPin(TEST_CLUTCH_DOWN_PIN) | |||
| 14 | .setClutchUpPin(TEST_CLUTCH_UP_PIN); | |||
| 15 | ||||
| 16 | 21 | void ShiftTorqueReductionSwitchTestBase::SetUp() { | ||
| 17 | 21 | TestBase::SetUp(); | ||
| 18 | 21 | setUpEngineConfiguration(TEST_ENGINE_CONFIG); | ||
| 19 | 21 | } | ||
| 20 | ||||
| 21 | 447 | void ShiftTorqueReductionSwitchTestBase::checkShiftTorqueReductionState( | ||
| 22 | const char* const context, | |||
| 23 | const bool expectedIsTorqueReductionTriggerPinValid, | |||
| 24 | const bool expectedTorqueReductionTriggerPinState | |||
| 25 | ) { | |||
| 26 | 447 | periodicFastCallback(); // to update isTorqueReductionTriggerPinValid and torqueReductionTriggerPinState | ||
| 27 |
2/6✓ Branch 3 taken 447 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 447 times.
✗ Branch 11 not taken.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
|
447 | EXPECT_EQ( | |
| 28 | engine->shiftTorqueReductionController.isTorqueReductionTriggerPinValid, | |||
| 29 | expectedIsTorqueReductionTriggerPinValid | |||
| 30 |
0/1✗ Branch 1 not taken.
|
447 | ) << context; | |
| 31 | ||||
| 32 |
2/6✓ Branch 3 taken 447 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 447 times.
✗ Branch 11 not taken.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
|
447 | EXPECT_EQ( | |
| 33 | engine->shiftTorqueReductionController.torqueReductionTriggerPinState, | |||
| 34 | expectedTorqueReductionTriggerPinState | |||
| 35 |
0/1✗ Branch 1 not taken.
|
447 | ) << context; | |
| 36 | 447 | } | ||
| 37 | ||||
| 38 | 426 | void ShiftTorqueReductionSwitchTestBase::setPinState(const TestSwitchPin pin, const bool state) { | ||
| 39 |
7/8✓ Branch 0 taken 62 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 66 times.
✓ Branch 6 taken 58 times.
✗ Branch 7 not taken.
|
426 | switch (pin) { | |
| 40 |
1/1✓ Decision 'true' taken 62 times.
|
62 | case TestSwitchPin::TORQUE_REDUCTION: { | |
| 41 | 62 | setMockState(TEST_TORQUE_REDUCTION_BUTTON_PIN, state);; | ||
| 42 | 62 | break; | ||
| 43 | } | |||
| 44 |
1/1✓ Decision 'true' taken 58 times.
|
58 | case TestSwitchPin::LUA_TORQUE_REDUCTION: { | |
| 45 | 58 | getTestLuaScriptExecutor().setTorqueReductionState(state); | ||
| 46 | 58 | break; | ||
| 47 | } | |||
| 48 |
1/1✓ Decision 'true' taken 62 times.
|
62 | case TestSwitchPin::LAUNCH: { | |
| 49 | 62 | setMockState(TEST_LAUNCH_BUTTON_PIN, state);; | ||
| 50 | 62 | break; | ||
| 51 | } | |||
| 52 |
1/1✓ Decision 'true' taken 62 times.
|
62 | case TestSwitchPin::CLUTCH_DOWN: { | |
| 53 | 62 | setMockState(TEST_CLUTCH_DOWN_PIN, state);; | ||
| 54 | 62 | break; | ||
| 55 | } | |||
| 56 |
1/1✓ Decision 'true' taken 58 times.
|
58 | case TestSwitchPin::LUA_CLUTCH_DOWN: { | |
| 57 | 58 | getTestLuaScriptExecutor().setClutchDownState(state); | ||
| 58 | 58 | break; | ||
| 59 | } | |||
| 60 |
1/1✓ Decision 'true' taken 66 times.
|
66 | case TestSwitchPin::CLUTCH_UP: { | |
| 61 | 66 | setMockState(TEST_CLUTCH_UP_PIN, state);; | ||
| 62 | 66 | break; | ||
| 63 | } | |||
| 64 |
1/1✓ Decision 'true' taken 58 times.
|
58 | case TestSwitchPin::LUA_CLUTCH_UP: { | |
| 65 | 58 | getTestLuaScriptExecutor().setClutchUpState(state); | ||
| 66 | 58 | break; | ||
| 67 | } | |||
| 68 | ✗ | default: { | ||
| 69 | ✗ | FAIL() << "Unexpected pin:" << static_cast<int>(pin); | ||
| 70 | break; | |||
| 71 | } | |||
| 72 | } | |||
| 73 | } | |||
| 74 |