| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Created by kifir on 10/3/24. | |||
| 3 | // | |||
| 4 | ||||
| 5 | #include "pch.h" | |||
| 6 | ||||
| 7 | #include "util/test_base.h" | |||
| 8 | ||||
| 9 | namespace { | |||
| 10 | constexpr float TEST_TORQUE_REDUCTION_ARMING_APP = 17.0f; | |||
| 11 | ||||
| 12 | class ShiftTorqueReductionAppConditionTest : public TestBase<> { | |||
| 13 | protected: | |||
| 14 | void checkAppCondition(std::optional<float> rpm, bool expectedAppCondition, const char* context); | |||
| 15 | }; | |||
| 16 | ||||
| 17 | 8 | void ShiftTorqueReductionAppConditionTest::checkAppCondition( | ||
| 18 | const std::optional<float> app, | |||
| 19 | const bool expectedAppCondition, | |||
| 20 | const char* const context | |||
| 21 | ) { | |||
| 22 | 8 | updateApp(app); | ||
| 23 |
2/7✓ Branch 3 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
|
8 | EXPECT_EQ(engine->shiftTorqueReductionController.isAppConditionSatisfied, expectedAppCondition) << context; | |
| 24 | 8 | } | ||
| 25 | ||||
| 26 | 4 | TEST_F(ShiftTorqueReductionAppConditionTest, checkZeroArmingApp) { | ||
| 27 |
1/1✓ Branch 2 taken 1 time.
|
3 | setUpEngineConfiguration(EngineConfig() | |
| 28 |
1/1✓ Branch 6 taken 1 time.
|
3 | .setTorqueReductionEnabled(true) | |
| 29 |
1/1✓ Branch 5 taken 1 time.
|
4 | .setTorqueReductionArmingApp(0.0f) | |
| 30 | ); | |||
| 31 |
1/1✓ Branch 4 taken 1 time.
|
1 | checkAppCondition(0.0f, true, "Zero APP"); | |
| 32 |
1/1✓ Branch 3 taken 1 time.
|
1 | checkAppCondition(TEST_TORQUE_REDUCTION_ARMING_APP, true, "Non-zero APP"); | |
| 33 |
1/1✓ Branch 3 taken 1 time.
|
1 | checkAppCondition({}, false, "Missed APP"); | |
| 34 | 1 | } | ||
| 35 | ||||
| 36 | 4 | TEST_F(ShiftTorqueReductionAppConditionTest, checkArmingApp) { | ||
| 37 |
1/1✓ Branch 2 taken 1 time.
|
3 | setUpEngineConfiguration(EngineConfig() | |
| 38 |
1/1✓ Branch 6 taken 1 time.
|
3 | .setTorqueReductionEnabled(true) | |
| 39 |
1/1✓ Branch 4 taken 1 time.
|
4 | .setTorqueReductionArmingApp(TEST_TORQUE_REDUCTION_ARMING_APP) | |
| 40 | ); | |||
| 41 | ||||
| 42 | 1 | periodicFastCallback(); | ||
| 43 |
1/7✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 21 not taken.
✗ Branch 24 not taken.
|
1 | EXPECT_FALSE(engine->shiftTorqueReductionController.isAppConditionSatisfied) << "Default"; | |
| 44 | ||||
| 45 |
1/1✓ Branch 4 taken 1 time.
|
1 | checkAppCondition(0.0f, false, "Zero APP"); | |
| 46 |
1/1✓ Branch 4 taken 1 time.
|
1 | checkAppCondition(TEST_TORQUE_REDUCTION_ARMING_APP - EPS5D, false, "Below arming APP"); | |
| 47 |
1/1✓ Branch 3 taken 1 time.
|
1 | checkAppCondition(TEST_TORQUE_REDUCTION_ARMING_APP, true, "Exact arming APP"); | |
| 48 |
1/1✓ Branch 4 taken 1 time.
|
1 | checkAppCondition(TEST_TORQUE_REDUCTION_ARMING_APP + EPS5D, true, "Above arming APP"); | |
| 49 |
1/1✓ Branch 3 taken 1 time.
|
1 | checkAppCondition({}, false, "Missed APP"); | |
| 50 | 1 | } | ||
| 51 | } | |||
| 52 |