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
+ void NitrousIgnitionRetardTest::checkBaseIgnitionAdvance (
19
+ const float expectedBaseIgnitionAdvance,
20
+ const char * const context
21
+ ) {
22
+ periodicFastCallback ();
23
+ EXPECT_NEAR (expectedBaseIgnitionAdvance, engine->ignitionState .baseIgnitionAdvance , EPS5D) << context;
24
+ }
25
+
26
+ TEST_F (NitrousIgnitionRetardTest, checkDefaultIgnitionRetardCorrection) {
27
+ setUpTestConfiguration ();
28
+ checkBaseIgnitionAdvance (EXPECTED_BASE_IGNITION_ADVANCE, " Default" );
29
+
30
+ activateNitrousControl ();
31
+ checkBaseIgnitionAdvance (EXPECTED_BASE_IGNITION_ADVANCE, " All conditions are satisfied" );
32
+
33
+ deactivateNitrousControl ();
34
+ checkBaseIgnitionAdvance (EXPECTED_BASE_IGNITION_ADVANCE, " No conditions are satisfied" );
35
+ }
36
+
37
+ TEST_F (NitrousIgnitionRetardTest, checkZeroIgnitionRetardCorrection) {
38
+ setUpTestConfiguration (/* nitrousFuelAdderPercent = */ {}, /* nitrousIgnitionRetard = */ { 0 .0f });
39
+ checkBaseIgnitionAdvance (EXPECTED_BASE_IGNITION_ADVANCE, " Default" );
40
+
41
+ activateNitrousControl ();
42
+ checkBaseIgnitionAdvance (EXPECTED_BASE_IGNITION_ADVANCE, " All conditions are satisfied" );
43
+
44
+ deactivateNitrousControl ();
45
+ checkBaseIgnitionAdvance (EXPECTED_BASE_IGNITION_ADVANCE, " No conditions are satisfied" );
46
+ }
47
+
48
+ TEST_F (NitrousIgnitionRetardTest, checkIgnitionRetardCorrection) {
49
+ setUpTestConfiguration (
50
+ /* nitrousFuelAdderPercent = */ {},
51
+ /* nitrousIgnitionRetard = */ { TEST_NITROUS_IGNITION_RETARD }
52
+ );
53
+ checkBaseIgnitionAdvance (EXPECTED_BASE_IGNITION_ADVANCE, " Default" );
54
+
55
+ activateNitrousControl ();
56
+ checkBaseIgnitionAdvance (
57
+ EXPECTED_BASE_IGNITION_ADVANCE - TEST_NITROUS_IGNITION_RETARD,
58
+ " All conditions are satisfied"
59
+ );
60
+
61
+ deactivateNitrousControl ();
62
+ checkBaseIgnitionAdvance (EXPECTED_BASE_IGNITION_ADVANCE, " No conditions are satisfied" );
63
+ }
64
+ }
0 commit comments