GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_rpm_condition.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 24 0 24
Functions: 100.0% 7 0 7
Branches: 64.3% 9 0 14
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 //
2 // Created by kifir on 10/3/24.
3 //
4
5 #include "pch.h"
6
7 #include "util/test_base.h"
8
9 namespace {
10 constexpr float TEST_TORQUE_REDUCTION_ARMING_RPM = 239.0f;
11
12 class ShiftTorqueReductionRpmConditionTest : public TestBase<> {
13 protected:
14 void checkRpmCondition(float rpm, bool expectedRpmCondition, const char* context);
15 };
16
17 6 void ShiftTorqueReductionRpmConditionTest::checkRpmCondition(
18 const float rpm,
19 const bool expectedRpmCondition,
20 const char* const context
21 ) {
22
1/1
✓ Branch 3 taken 6 times.
6 updateRpm(rpm);
23
2/7
✓ Branch 3 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
6 EXPECT_EQ(engine->shiftTorqueReductionController.isRpmConditionSatisfied, expectedRpmCondition) << context;
24 6 }
25
26 4 TEST_F(ShiftTorqueReductionRpmConditionTest, checkZeroArmingRpm) {
27
1/1
✓ Branch 2 taken 1 time.
3 setUpEngineConfiguration(EngineConfig()
28
1/1
✓ Branch 6 taken 1 time.
3 .setTorqueReductionEnabled(true)
29
1/1
✓ Branch 5 taken 1 time.
4 .setTorqueReductionArmingRpm(0.0f)
30 );
31 1 checkRpmCondition(0.0f, true, "Zero RPM");
32 1 checkRpmCondition(TEST_TORQUE_REDUCTION_ARMING_RPM, true, "Non-zero RPM");
33 1 }
34
35 4 TEST_F(ShiftTorqueReductionRpmConditionTest, checkArmingRpm) {
36
1/1
✓ Branch 2 taken 1 time.
3 setUpEngineConfiguration(EngineConfig()
37
1/1
✓ Branch 6 taken 1 time.
3 .setTorqueReductionEnabled(true)
38
1/1
✓ Branch 4 taken 1 time.
4 .setTorqueReductionArmingRpm(TEST_TORQUE_REDUCTION_ARMING_RPM)
39 );
40 1 checkRpmCondition(0.0f, false, "Zero RPM");
41 1 checkRpmCondition(TEST_TORQUE_REDUCTION_ARMING_RPM - EPS5D, false, "Below arming RPM");
42 1 checkRpmCondition(TEST_TORQUE_REDUCTION_ARMING_RPM, true, "Exact arming RPM");
43 1 checkRpmCondition(TEST_TORQUE_REDUCTION_ARMING_RPM + EPS5D, true, "Above arming RPM");
44 1 }
45 }
46