Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | // | |||
2 | // Created by kifir on 11/5/24. | |||
3 | // | |||
4 | ||||
5 | #include "pch.h" | |||
6 | ||||
7 | #include "flat_shift_condition_test_base.h" | |||
8 | ||||
9 | constexpr float TEST_IGNITION_RETARD = 17.4; | |||
10 | constexpr float TEST_TORQUE_REDUCTION_IGNITION_RETARD = 23.0f; | |||
11 | ||||
12 | namespace { | |||
13 | class ShiftTorqueReductionAngleAdvanceTest : public FlatShiftConditionTestBase { | |||
14 | protected: | |||
15 | ShiftTorqueReductionAngleAdvanceTest(); | |||
16 | ||||
17 | void SetUp() override; | |||
18 | ||||
19 | void checkBaseIgnitionAdvance(const char* context, float expectedAdvance); | |||
20 | private: | |||
21 | void configureTestIgnitionTable(); | |||
22 | }; | |||
23 | ||||
24 | 1 | ShiftTorqueReductionAngleAdvanceTest::ShiftTorqueReductionAngleAdvanceTest() | ||
25 | 1 | : FlatShiftConditionTestBase(0, TEST_TORQUE_REDUCTION_IGNITION_RETARD) { | ||
26 | 1 | } | ||
27 | ||||
28 | 1 | void ShiftTorqueReductionAngleAdvanceTest::SetUp() { | ||
29 | 1 | FlatShiftConditionTestBase::SetUp(); | ||
30 | 1 | configureTestIgnitionTable(); | ||
31 | 1 | setTable(config->torqueReductionIgnitionRetardTable, TEST_TORQUE_REDUCTION_IGNITION_RETARD); | ||
32 | 1 | } | ||
33 | ||||
34 | 3 | void ShiftTorqueReductionAngleAdvanceTest::checkBaseIgnitionAdvance( | ||
35 | const char* const context, | |||
36 | const float expectedAdvance | |||
37 | ) { | |||
38 | 3 | periodicFastCallback(); | ||
39 |
2/7✓ Branch 3 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 10 not taken.
✗ Branch 13 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
|
3 | EXPECT_NEAR(expectedAdvance, engine->ignitionState.baseIgnitionAdvance, EPS5D) << context; | |
40 | 3 | } | ||
41 | ||||
42 | 1 | void ShiftTorqueReductionAngleAdvanceTest::configureTestIgnitionTable() { | ||
43 | 1 | IgnitionTable testIgnitionTable; | ||
44 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 time.
|
2/2✓ Decision 'true' taken 16 times.
✓ Decision 'false' taken 1 time.
|
34 | for (IgnitionTable::size_type loadIdx = 0; loadIdx < testIgnitionTable.size(); loadIdx++) { |
45 | 16 | const IgnitionTable::value_type& rpms = testIgnitionTable[loadIdx]; | ||
46 |
2/2✓ Branch 0 taken 256 times.
✓ Branch 1 taken 16 times.
|
2/2✓ Decision 'true' taken 256 times.
✓ Decision 'false' taken 16 times.
|
288 | for (IgnitionTable::size_type rpmIdx = 0; rpmIdx < rpms.size(); rpmIdx++) { |
47 | 256 | testIgnitionTable[loadIdx][rpmIdx] = TEST_IGNITION_RETARD; | ||
48 | } | |||
49 | }; | |||
50 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | getTestPersistentConfiguration().setIgnitionTable(testIgnitionTable); | |
51 | 1 | } | ||
52 | ||||
53 | 4 | TEST_F(ShiftTorqueReductionAngleAdvanceTest, checkAngleAdvance) { | ||
54 | 1 | checkBaseIgnitionAdvance("Initial state", TEST_IGNITION_RETARD); | ||
55 | ||||
56 | 1 | satisfyFlatShiftCondition(); | ||
57 | 1 | checkBaseIgnitionAdvance("Flat Shift condition is satisfied", TEST_TORQUE_REDUCTION_IGNITION_RETARD); | ||
58 | ||||
59 | 1 | unsatisfyFlatShiftCondition(); | ||
60 | 1 | checkBaseIgnitionAdvance("Flat Shift condition is not satisfied", TEST_IGNITION_RETARD); | ||
61 | 1 | } | ||
62 | } | |||
63 |