GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/ac/ac_test_base.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 96.3% 26 0 27
Functions: 100.0% 6 0 6
Branches: 47.6% 20 0 42
Decisions: 87.5% 7 - 8

Line Branch Decision Exec Source
1 //
2 // Created by kifir on 6/18/24.
3 //
4
5 #include "pch.h"
6
7 #include "ac_test_base.h"
8 #include "engine_configuration_defaults.h"
9
10 27 void AcTestBase::updateAcPressure(float acPressure) {
11 27 Sensor::setMockValue(SensorType::AcPressure, acPressure);
12 27 periodicSlowCallback();
13 27 }
14
15 5 void AcTestBase::setUpTestConfig(const AcTestConfig& config) {
16 5 configureAcDelay(config.getAcDelay());
17 5 configureMinAcPressure(config.getMinAcPressure());
18 5 configureMaxAcPressure(config.getMaxAcPressure());
19 5 configureAcPressureEnableHysteresis(config.getAcPressureEnableHysteresis());
20 5 }
21
22 5 void AcTestBase::configureAcDelay(const std::optional<float> acDelay) {
23
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
1/2
✗ Decision 'true' not taken.
✓ Decision 'false' taken 5 times.
5 if (acDelay.has_value()) {
24 engineConfiguration->acDelay = acDelay.value();
25 } else {
26
3/8
✓ Branch 2 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 24 taken 5 times.
✗ Branch 25 not taken.
5 ASSERT_EQ(engineConfiguration->acDelay, engine_configuration_defaults::AC_DELAY); // check default value
27 }
28 }
29
30 5 void AcTestBase::configureMinAcPressure(const std::optional<uint16_t> minAcPressure) {
31
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
2/2
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 3 times.
5 if (minAcPressure.has_value()) {
32 2 engineConfiguration->minAcPressure = minAcPressure.value();
33 } else {
34
3/8
✓ Branch 2 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 24 taken 3 times.
✗ Branch 25 not taken.
3 ASSERT_EQ(engineConfiguration->minAcPressure, engine_configuration_defaults::MIN_AC_PRESSURE); // check default value
35 }
36 }
37
38 5 void AcTestBase::configureMaxAcPressure(const std::optional<uint16_t> maxAcPressure) {
39
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
2/2
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 3 times.
5 if (maxAcPressure.has_value()) {
40 2 engineConfiguration->maxAcPressure = maxAcPressure.value();
41 } else {
42
3/8
✓ Branch 2 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✓ Branch 24 taken 3 times.
✗ Branch 25 not taken.
3 ASSERT_EQ(engineConfiguration->maxAcPressure, engine_configuration_defaults::MAX_AC_PRESSURE); // check default value
43 }
44 }
45
46 5 void AcTestBase::configureAcPressureEnableHysteresis(std::optional<float> acPressureEnableHysteresis) {
47
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
2/2
✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 2 times.
5 if (acPressureEnableHysteresis.has_value()) {
48
1/1
✓ Branch 2 taken 3 times.
3 engineConfiguration->acPressureEnableHyst = acPressureEnableHysteresis.value();
49 } else {
50
2/6
✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
2 ASSERT_EQ(
51 engineConfiguration->acPressureEnableHyst,
52 engine_configuration_defaults::AC_PRESSURE_ENABLE_HYST
53
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ); // check default value
54 }
55 }
56