GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/shift_torque_reduction/shift_torque_reduction_switch_test_base.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 94.4% 34 0 36
Functions: 100.0% 3 0 3
Branches: 40.7% 11 0 27
Decisions: 87.5% 7 - 8

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