GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/controllers/modules/vvl_controller/vvl_controller_clt_condition.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 30 0 30
Functions: 100.0% 10 0 10
Branches: 77.3% 17 0 22
Decisions: 100.0% 2 - 2

Line Branch Decision Exec Source
1 /*
2 * @file vvl_controller_clt_condition.cpp
3 *
4 * @date: ago 26, 2025
5 * @author FDSoftware, kifir
6 */
7
8 #include "pch.h"
9
10 #include "engine_configuration_defaults.h"
11
12 #include "util/test_base.h"
13
14 namespace {
15 static constexpr uint8_t TEST_MIN_CLT = 51;
16 struct CltConditionTestData {
17 const std::optional<float> clt;
18 const bool expectedCltCondition;
19 const char* const context;
20 };
21
22 3 void checkCltCondition(const std::vector<CltConditionTestData>& testData) {
23
2/2
✓ Branch 7 taken 15 times.
✓ Branch 8 taken 3 times.
2/2
✓ Decision 'true' taken 15 times.
✓ Decision 'false' taken 3 times.
18 for (const CltConditionTestData& item: testData) {
24
1/1
✓ Branch 3 taken 15 times.
15 Sensor::setMockValue(SensorType::Clt, item.clt.value_or(0.0f));
25
2/2
✓ Branch 1 taken 15 times.
✓ Branch 5 taken 15 times.
15 engine->module<VvlController>().unmock().onSlowCallback();
26
3/7
✓ Branch 3 taken 15 times.
✓ Branch 7 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 15 times.
✗ Branch 15 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
15 EXPECT_EQ(engine->module<VvlController>().unmock().isVvlCltCondition, item.expectedCltCondition)
27
0/1
✗ Branch 1 not taken.
15 << item.context;
28 }
29 3 }
30
31 4 TEST(VvlCltConditionTest, checkDefaultWithDisabledVvlControl) {
32
1/1
✓ Branch 2 taken 1 time.
1 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
33 1 engineConfiguration->vvlControlEnabled = false;
34
35
2/2
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 checkCltCondition({
36 { {}, false, "default" },
37 { { 0.0f }, false, "0.0" },
38 { { TEST_MIN_CLT - EPS5D }, false, "TEST_MIN_CLT - EPS5D" },
39 { { TEST_MIN_CLT }, false, "TEST_MIN_CLT" },
40 { { TEST_MIN_CLT + EPS5D }, false, "TEST_MIN_CLT + EPS5D" },
41 });
42 2 }
43
44 4 TEST(VvlCltConditionTest, checkZeroMinimumClt) {
45
1/1
✓ Branch 2 taken 1 time.
1 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
46 1 engineConfiguration->vvlControlEnabled = true;
47 1 engineConfiguration->vvlController.minimumClt = 0;
48
49
2/2
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 checkCltCondition({
50 { {}, true, "default" },
51 { { 0.0f }, true, "0.0" },
52 { { TEST_MIN_CLT - EPS5D }, true, "TEST_MIN_CLT - EPS5D" },
53 { { TEST_MIN_CLT }, true, "TEST_MIN_CLT" },
54 { { TEST_MIN_CLT + EPS5D }, true, "TEST_MIN_CLT + EPS5D" },
55 });
56 2 }
57
58 4 TEST(VvlCltConditionTest, checkMinimumClt) {
59
1/1
✓ Branch 2 taken 1 time.
1 EngineTestHelper eth(engine_type_e::TEST_ENGINE);
60 1 engineConfiguration->vvlControlEnabled = true;
61 1 engineConfiguration->vvlController.minimumClt = TEST_MIN_CLT;
62
63
2/2
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
3 checkCltCondition({
64 { {}, false, "default" },
65 { { 0.0f }, false, "0.0" },
66 { { TEST_MIN_CLT - EPS5D }, false, "TEST_MIN_CLT - EPS5D" },
67 { { TEST_MIN_CLT }, true, "TEST_MIN_CLT" },
68 { { TEST_MIN_CLT + EPS5D }, true, "TEST_MIN_CLT + EPS5D" },
69 });
70 2 }
71 }
72