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