GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/nitrous_control/test_nitrous_clt_condition.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 41 0 41
Functions: 100.0% 16 0 16
Branches: 83.9% 26 0 31
Decisions: 100.0% 2 - 2

Line Branch Decision Exec Source
1 //
2 // Created by kifir on 11/28/24.
3 //
4
5 #include "pch.h"
6
7 #include "engine_configuration_defaults.h"
8
9 #include "util/test_base.h"
10
11 namespace {
12 struct CltConditionTestData {
13 const std::optional<float> clt;
14 const bool expectedCltCondition;
15 const char* const context;
16 };
17
18 class NitrousCltConditionTest : public TestBase<> {
19 protected:
20 static constexpr uint8_t TEST_MIN_CLT = 51;
21
22 void checkCltCondition(const std::vector<CltConditionTestData>& testData);
23 };
24
25 5 void NitrousCltConditionTest::checkCltCondition(const std::vector<CltConditionTestData>& testData) {
26
2/2
✓ Branch 7 taken 25 times.
✓ Branch 8 taken 5 times.
2/2
✓ Decision 'true' taken 25 times.
✓ Decision 'false' taken 5 times.
30 for (const CltConditionTestData& item: testData) {
27
1/1
✓ Branch 1 taken 25 times.
25 updateClt(item.clt, &TestBase::periodicSlowCallback);
28
3/7
✓ Branch 3 taken 25 times.
✓ Branch 6 taken 25 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 25 times.
✗ Branch 14 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
25 EXPECT_EQ(getModule<NitrousController>().isNitrousCltCondition, item.expectedCltCondition)
29
0/1
✗ Branch 1 not taken.
25 << item.context;
30 }
31 5 }
32
33 4 TEST_F(NitrousCltConditionTest, checkDefault) {
34
2/2
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 checkCltCondition({
35 { {}, false, "default" },
36 { { 0 }, false, "0.0" },
37 { { TEST_MIN_CLT - EPS5D }, false, "TEST_MIN_CLT - EPS5D" },
38 { { TEST_MIN_CLT }, false, "TEST_MIN_CLT" },
39 { { TEST_MIN_CLT + EPS5D }, false, "TEST_MIN_CLT + EPS5D" },
40 });
41 1 }
42
43 4 TEST_F(NitrousCltConditionTest, checkDefaultWithDisabledNitrousControl) {
44
2/2
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 setUpEngineConfiguration(EngineConfig().setNitrousControlEnabled({ false }));
45
2/2
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 checkCltCondition({
46 { {}, false, "default" },
47 { { 0.0f }, false, "0.0" },
48 { { TEST_MIN_CLT - EPS5D }, false, "TEST_MIN_CLT - EPS5D" },
49 { { TEST_MIN_CLT }, false, "TEST_MIN_CLT" },
50 { { TEST_MIN_CLT + EPS5D }, false, "TEST_MIN_CLT + EPS5D" },
51 });
52 1 }
53
54 4 TEST_F(NitrousCltConditionTest, checkDefaultWithEnabledNitrousControl) {
55
2/2
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 setUpEngineConfiguration(EngineConfig().setNitrousControlEnabled({ true }));
56
2/2
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 checkCltCondition({
57 { {}, false, "default" },
58 { { 0.0f }, false, "0.0" },
59 { { engine_configuration_defaults::NITROUS_MINIMUM_CLT - EPS5D }, false, "NITROUS_MINIMUM_CLT - EPS5D" },
60 { { engine_configuration_defaults::NITROUS_MINIMUM_CLT }, true, "NITROUS_MINIMUM_CLT" },
61 { { engine_configuration_defaults::NITROUS_MINIMUM_CLT + EPS5D }, true, "NITROUS_MINIMUM_CLT + EPS5D" },
62 });
63 1 }
64
65 4 TEST_F(NitrousCltConditionTest, checkZeroMinimumClt) {
66
1/1
✓ Branch 2 taken 1 time.
2 setUpEngineConfiguration(
67 1 EngineConfig()
68
1/1
✓ Branch 6 taken 1 time.
3 .setNitrousControlEnabled({ true })
69
1/1
✓ Branch 5 taken 1 time.
4 .setNitrousMinimumClt(0)
70 );
71
2/2
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 checkCltCondition({
72 { {}, true, "default" },
73 { { 0.0f }, true, "0.0" },
74 { { TEST_MIN_CLT - EPS5D }, true, "TEST_MIN_CLT - EPS5D" },
75 { { TEST_MIN_CLT }, true, "TEST_MIN_CLT" },
76 { { TEST_MIN_CLT + EPS5D }, true, "TEST_MIN_CLT + EPS5D" },
77 });
78 1 }
79
80 4 TEST_F(NitrousCltConditionTest, checkMinimumClt) {
81
1/1
✓ Branch 2 taken 1 time.
2 setUpEngineConfiguration(
82 1 EngineConfig()
83
1/1
✓ Branch 6 taken 1 time.
3 .setNitrousControlEnabled({ true })
84
1/1
✓ Branch 4 taken 1 time.
4 .setNitrousMinimumClt({ TEST_MIN_CLT })
85 );
86
2/2
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 checkCltCondition({
87 { {}, false, "default" },
88 { { 0.0f }, false, "0.0" },
89 { { TEST_MIN_CLT - EPS5D }, false, "TEST_MIN_CLT - EPS5D" },
90 { { TEST_MIN_CLT }, true, "TEST_MIN_CLT" },
91 { { TEST_MIN_CLT + EPS5D }, true, "TEST_MIN_CLT + EPS5D" },
92 });
93 1 }
94 }
95