GCC Code Coverage Report


Directory: ./
File: unit_tests/tests/nitrous_control/test_nitrous_fuel_adder.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 19 0 19
Functions: 100.0% 5 0 5
Branches: 37.5% 3 0 8
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 //
2 // Created by kifir on 12/5/24.
3 //
4
5 #include "pch.h"
6
7 #include "nitrous_test_base.h"
8
9 namespace {
10 class NitrousFuelAdderTest : public NitrousTestBase {
11 protected:
12 static constexpr int8_t TEST_NITROUS_FUEL_ADDER_PERCENT = 17;
13 static constexpr float DEFAULT_FUEL_CORRECTION = 1.009999f;
14 static const CltFuelCorrCurve TEST_CLT_FUEL_CORR;
15
16 void checkTotalFuelCorrection(
17 bool expectedNitrousCondition,
18 float expectedTotalFuelCorrection,
19 const char* context
20 );
21 public:
22 static CltFuelCorrCurve generateTestCltFuelCorrCurve();
23 };
24
25 3 void NitrousFuelAdderTest::checkTotalFuelCorrection(
26 const bool expectedNitrousCondition,
27 const float expectedTotalFuelCorrection,
28 const char* const context
29 ) {
30 3 periodicFastCallback(); // to recalculate total fuel correction
31 3 checkNitrousCondition(expectedNitrousCondition, context);
32
2/7
✓ Branch 2 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
3 EXPECT_NEAR(engine->fuelComputer.totalFuelCorrection, expectedTotalFuelCorrection, EPS5D) << context;
33 3 }
34
35 1 CltFuelCorrCurve NitrousFuelAdderTest::generateTestCltFuelCorrCurve() {
36 CltFuelCorrCurve result;
37 1 result.fill(DEFAULT_FUEL_CORRECTION);
38 1 return result;
39 }
40
41 const CltFuelCorrCurve NitrousFuelAdderTest::TEST_CLT_FUEL_CORR = NitrousFuelAdderTest::generateTestCltFuelCorrCurve();
42
43 4 TEST_F(NitrousFuelAdderTest, checkFuelCorrection) {
44
1/1
✓ Branch 5 taken 1 time.
1 setUpTestConfiguration({ TEST_NITROUS_FUEL_ADDER_PERCENT });
45 1 getTestPersistentConfiguration().setCltFuelCorrCurve(TEST_CLT_FUEL_CORR); // constant fuel CLT correction
46
47 1 checkTotalFuelCorrection(false, DEFAULT_FUEL_CORRECTION, "Default");
48
49 1 activateNitrousControl();
50 1 checkTotalFuelCorrection(
51 true,
52 DEFAULT_FUEL_CORRECTION * (1.0f + TEST_NITROUS_FUEL_ADDER_PERCENT / 100.0f),
53 "All conditions are satisfied"
54 );
55
56 1 deactivateNitrousControl();
57 1 checkTotalFuelCorrection(false, DEFAULT_FUEL_CORRECTION, "No conditions are satisfied");
58 1 }
59 }
60