GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/shift_torque_reduction/test_shift_torque_reduction_spark_skip_ratio.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 22 0 22
Functions: 100.0% 6 0 6
Branches: 28.6% 4 0 14
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 //
2 // Created by kifir on 11/4/24.
3 //
4
5 #include "pch.h"
6
7 #include "flat_shift_condition_test_base.h"
8
9 namespace {
10 constexpr float TEST_LUA_SOFT_SPARK_SKIP = 1.23f;
11 constexpr float TEST_LUA_HARD_SPARK_SKIP = 4.56f;
12
13 constexpr int8_t TEST_TORQUE_REDUCTION_IGNITION_CUT = 17;
14
15 class ShiftTorqueReductionSparkSkipRatioTest : public FlatShiftConditionTestBase {
16 protected:
17 ShiftTorqueReductionSparkSkipRatioTest();
18
19 void SetUp() override;
20
21 void checkTargetSkipRatios(
22 const char* context,
23 float expectedHardSparkLimiterTargetSkipRatio = TEST_LUA_HARD_SPARK_SKIP
24 );
25 };
26
27 1 ShiftTorqueReductionSparkSkipRatioTest::ShiftTorqueReductionSparkSkipRatioTest()
28 1 : FlatShiftConditionTestBase(TEST_TORQUE_REDUCTION_IGNITION_CUT, 0.0f) {
29 1 }
30
31 1 void ShiftTorqueReductionSparkSkipRatioTest::SetUp() {
32 1 FlatShiftConditionTestBase::SetUp();
33
34 1 getTestLuaScriptExecutor().setSparkSkipRatio(TEST_LUA_SOFT_SPARK_SKIP);
35 1 getTestLuaScriptExecutor().setSparkHardSkipRatio(TEST_LUA_HARD_SPARK_SKIP);
36 1 }
37
38 3 void ShiftTorqueReductionSparkSkipRatioTest::checkTargetSkipRatios(
39 const char* const context,
40 const float expectedHardSparkLimiterTargetSkipRatio
41 ) {
42 3 periodicFastCallback();
43
2/7
✓ Branch 4 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 12 not taken.
✗ Branch 15 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
3 EXPECT_EQ(engine->softSparkLimiter.getTargetSkipRatio(), TEST_LUA_SOFT_SPARK_SKIP) << context;
44
2/7
✓ Branch 4 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 12 not taken.
✗ Branch 15 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
3 EXPECT_EQ(engine->hardSparkLimiter.getTargetSkipRatio(), expectedHardSparkLimiterTargetSkipRatio) << context;
45 3 }
46
47 4 TEST_F(ShiftTorqueReductionSparkSkipRatioTest, checkHardSparkLimiterTargetSkipRatio) {
48 1 checkTargetSkipRatios("Initial state");
49
50 1 satisfyFlatShiftCondition();
51 1 checkTargetSkipRatios(
52 "Flat Shift condition is satisfied",
53 TEST_LUA_HARD_SPARK_SKIP + TEST_TORQUE_REDUCTION_IGNITION_CUT / 100.0f
54 );
55
56 1 unsatisfyFlatShiftCondition();
57 1 checkTargetSkipRatios("Flat Shift condition is not satisfied");
58 1 }
59 }
60