| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Created by kifir on 12/6/24. | |||
| 3 | // | |||
| 4 | ||||
| 5 | #include "pch.h" | |||
| 6 | ||||
| 7 | #include "nitrous_test_base.h" | |||
| 8 | ||||
| 9 | namespace { | |||
| 10 | class NitrousIgnitionRetardTest : public NitrousTestBase { | |||
| 11 | protected: | |||
| 12 | static constexpr float EXPECTED_BASE_IGNITION_ADVANCE = 10.5f; | |||
| 13 | static constexpr float TEST_NITROUS_IGNITION_RETARD = 1.78f; | |||
| 14 | ||||
| 15 | void checkBaseIgnitionAdvance(float expectedBaseIgnitionAdvance, const char* context); | |||
| 16 | }; | |||
| 17 | ||||
| 18 | 9 | void NitrousIgnitionRetardTest::checkBaseIgnitionAdvance( | ||
| 19 | const float expectedBaseIgnitionAdvance, | |||
| 20 | const char* const context | |||
| 21 | ) { | |||
| 22 | 9 | periodicFastCallback(); | ||
| 23 |
2/7✓ Branch 3 taken 9 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 10 not taken.
✗ Branch 13 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
|
9 | EXPECT_NEAR(expectedBaseIgnitionAdvance, engine->ignitionState.baseIgnitionAdvance, EPS5D) << context; | |
| 24 | 9 | } | ||
| 25 | ||||
| 26 | 4 | TEST_F(NitrousIgnitionRetardTest, checkDefaultIgnitionRetardCorrection) { | ||
| 27 |
1/1✓ Branch 5 taken 1 time.
|
1 | setUpTestConfiguration(); | |
| 28 | 1 | checkBaseIgnitionAdvance(EXPECTED_BASE_IGNITION_ADVANCE, "Default"); | ||
| 29 | ||||
| 30 | 1 | activateNitrousControl(); | ||
| 31 | 1 | checkBaseIgnitionAdvance(EXPECTED_BASE_IGNITION_ADVANCE, "All conditions are satisfied"); | ||
| 32 | ||||
| 33 | 1 | deactivateNitrousControl(); | ||
| 34 | 1 | checkBaseIgnitionAdvance(EXPECTED_BASE_IGNITION_ADVANCE, "No conditions are satisfied"); | ||
| 35 | 1 | } | ||
| 36 | ||||
| 37 | 4 | TEST_F(NitrousIgnitionRetardTest, checkZeroIgnitionRetardCorrection) { | ||
| 38 |
1/1✓ Branch 6 taken 1 time.
|
1 | setUpTestConfiguration(/* nitrousFuelAdderPercent = */ {}, /* nitrousIgnitionRetard = */ { 0.0f }); | |
| 39 | 1 | checkBaseIgnitionAdvance(EXPECTED_BASE_IGNITION_ADVANCE, "Default"); | ||
| 40 | ||||
| 41 | 1 | activateNitrousControl(); | ||
| 42 | 1 | checkBaseIgnitionAdvance(EXPECTED_BASE_IGNITION_ADVANCE, "All conditions are satisfied"); | ||
| 43 | ||||
| 44 | 1 | deactivateNitrousControl(); | ||
| 45 | 1 | checkBaseIgnitionAdvance(EXPECTED_BASE_IGNITION_ADVANCE, "No conditions are satisfied"); | ||
| 46 | 1 | } | ||
| 47 | ||||
| 48 | 4 | TEST_F(NitrousIgnitionRetardTest, checkIgnitionRetardCorrection) { | ||
| 49 |
1/1✓ Branch 5 taken 1 time.
|
1 | setUpTestConfiguration( | |
| 50 | /* nitrousFuelAdderPercent = */ {}, | |||
| 51 | /* nitrousIgnitionRetard = */ { TEST_NITROUS_IGNITION_RETARD } | |||
| 52 | ); | |||
| 53 | 1 | checkBaseIgnitionAdvance(EXPECTED_BASE_IGNITION_ADVANCE, "Default"); | ||
| 54 | ||||
| 55 | 1 | activateNitrousControl(); | ||
| 56 | 1 | checkBaseIgnitionAdvance( | ||
| 57 | EXPECTED_BASE_IGNITION_ADVANCE - TEST_NITROUS_IGNITION_RETARD, | |||
| 58 | "All conditions are satisfied" | |||
| 59 | ); | |||
| 60 | ||||
| 61 | 1 | deactivateNitrousControl(); | ||
| 62 | 1 | checkBaseIgnitionAdvance(EXPECTED_BASE_IGNITION_ADVANCE, "No conditions are satisfied"); | ||
| 63 | 1 | } | ||
| 64 | } | |||
| 65 |