GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 53 / 0 / 53
Functions: 100.0% 13 / 0 / 13
Branches: 41.6% 32 / 0 / 77
Decisions: -% 0 / - / 0

unit_tests/tests/controllers/algo/rotational_idle/test_rotational_idle.cpp
Line Branch Decision Exec Source
1 /*
2 * @file test_rotational_idle.cpp
3 *
4 * @date: ene 18, 2026
5 * @author FDSoftware
6 */
7
8 #include "pch.h"
9 #include "rotational_idle.h"
10
11 class RotationalIdleTest : public ::testing::Test
12 {
13 protected:
14 4 void SetUp() override
15 {
16
1/1
✓ Branch 2 taken 4 times.
4 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
17
18 // Reset configuration
19 4 engineConfiguration->rotationalIdleController.enabled = false;
20 4 engineConfiguration->rotationalIdleController.auto_engage = false;
21 4 engineConfiguration->rotationalIdleController.auto_engage_clt_enable = false;
22 4 engineConfiguration->rotationalIdleController.max_tps = 5;
23 4 engineConfiguration->rotationalIdleController.auto_engage_clt = 80;
24 8 }
25 };
26
27 4 TEST_F(RotationalIdleTest, disabledFeature)
28 {
29
1/1
✓ Branch 2 taken 1 time.
1 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
30
1/1
✓ Branch 2 taken 1 time.
1 RotationalIdle rotIdle;
31
32 // Feature disabled
33 1 engineConfiguration->rotationalIdleController.enabled = false;
34
35
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_FALSE(rotIdle.shouldEngageRotationalIdle());
36 2 }
37
38 4 TEST_F(RotationalIdleTest, autoEngageByClt)
39 {
40
1/1
✓ Branch 2 taken 1 time.
1 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
41
1/1
✓ Branch 2 taken 1 time.
1 RotationalIdle rotIdle;
42
43 1 engineConfiguration->rotationalIdleController.enabled = true;
44 1 engineConfiguration->rotationalIdleController.auto_engage_clt_enable = true;
45 1 engineConfiguration->rotationalIdleController.auto_engage_clt = 80;
46
47 // CLT below threshold - should not engage
48
1/1
✓ Branch 1 taken 1 time.
1 Sensor::setMockValue(SensorType::Clt, 70);
49
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_FALSE(rotIdle.shouldEngageRotationalIdle());
50
51 // CLT above threshold - should engage
52
1/1
✓ Branch 1 taken 1 time.
1 Sensor::setMockValue(SensorType::Clt, 85);
53
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(rotIdle.shouldEngageRotationalIdle());
54 2 }
55
56 4 TEST_F(RotationalIdleTest, autoEngageByTps)
57 {
58
1/1
✓ Branch 2 taken 1 time.
1 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
59
1/1
✓ Branch 2 taken 1 time.
1 RotationalIdle rotIdle;
60
61 1 engineConfiguration->rotationalIdleController.enabled = true;
62 1 engineConfiguration->rotationalIdleController.auto_engage = true;
63 1 engineConfiguration->rotationalIdleController.max_tps = 5;
64
65 // TPS above threshold - should not engage
66
1/1
✓ Branch 1 taken 1 time.
1 Sensor::setMockValue(SensorType::DriverThrottleIntent, 10);
67
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_FALSE(rotIdle.shouldEngageRotationalIdle());
68
69 // TPS below threshold - should engage
70
1/1
✓ Branch 1 taken 1 time.
1 Sensor::setMockValue(SensorType::DriverThrottleIntent, 3);
71
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(rotIdle.shouldEngageRotationalIdle());
72
73 // TPS at threshold - should engage
74
1/1
✓ Branch 1 taken 1 time.
1 Sensor::setMockValue(SensorType::DriverThrottleIntent, 5);
75
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_TRUE(rotIdle.shouldEngageRotationalIdle());
76 2 }
77
78 4 TEST_F(RotationalIdleTest, shouldSkipSpark)
79 {
80
1/1
✓ Branch 2 taken 1 time.
1 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
81
1/1
✓ Branch 2 taken 1 time.
1 RotationalIdle rotIdle;
82
83 // Test with various offsets
84
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_FALSE(rotIdle.shouldSkipSparkRotationalIdle(0));
85
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_FALSE(rotIdle.shouldSkipSparkRotationalIdle(1));
86
2/7
✓ Branch 3 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
1 EXPECT_FALSE(rotIdle.shouldSkipSparkRotationalIdle(-1));
87 2 }
88