Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | // | |||
2 | // Created by kifir on 5/17/24. | |||
3 | // | |||
4 | ||||
5 | #include "pch.h" | |||
6 | ||||
7 | #include "util/test_base.h" | |||
8 | ||||
9 | namespace { | |||
10 | constexpr float TEST_TRACTION_CONTROL_IGNITION_SKIP = 17.0f; | |||
11 | constexpr float TEST_LUA_SOFT_SPARK_SKIP = 239.0f; | |||
12 | constexpr float TEST_LUA_HARD_SPARK_SKIP = 174.0f; | |||
13 | ||||
14 | class LaunchTargetSkipRatioTest : public TestBase<> { | |||
15 | protected: | |||
16 | void SetUp() override; | |||
17 | }; | |||
18 | ||||
19 | 2 | void LaunchTargetSkipRatioTest::SetUp() { | ||
20 | 2 | TestBase::SetUp(); | ||
21 | 2 | std::fill_n( | ||
22 | 2 | &engineConfiguration->tractionControlIgnitionSkip[0][0], | ||
23 | TRACTION_CONTROL_ETB_DROP_SLIP_SIZE * TRACTION_CONTROL_ETB_DROP_SPEED_SIZE, | |||
24 |
1/1✓ Branch 1 taken 2 times.
|
2 | static_cast<int8_t>(TEST_TRACTION_CONTROL_IGNITION_SKIP) | |
25 | ); | |||
26 | 2 | getTestLuaScriptExecutor().setSparkSkipRatio(TEST_LUA_SOFT_SPARK_SKIP); | ||
27 | 2 | getTestLuaScriptExecutor().setSparkHardSkipRatio(TEST_LUA_HARD_SPARK_SKIP); | ||
28 | 2 | } | ||
29 | ||||
30 | 4 | TEST_F(LaunchTargetSkipRatioTest, doNotUseSkipInTraction) { | ||
31 |
1/6✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✗ Branch 18 not taken.
✗ Branch 21 not taken.
|
1 | EXPECT_FALSE(engineConfiguration->useHardSkipInTraction); | |
32 | ||||
33 | 1 | periodicFastCallback(); | ||
34 |
2/6✓ Branch 5 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_EQ(engine->softSparkLimiter.getTargetSkipRatio(), TEST_LUA_SOFT_SPARK_SKIP + TEST_TRACTION_CONTROL_IGNITION_SKIP); | |
35 |
2/6✓ Branch 4 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
|
1 | EXPECT_EQ(engine->hardSparkLimiter.getTargetSkipRatio(), TEST_LUA_HARD_SPARK_SKIP); | |
36 | 1 | } | ||
37 | ||||
38 | 4 | TEST_F(LaunchTargetSkipRatioTest, useSkipInTraction) { | ||
39 | 1 | engineConfiguration->useHardSkipInTraction = true; | ||
40 | ||||
41 | 1 | periodicFastCallback(); | ||
42 |
2/6✓ Branch 4 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 17 not taken.
✗ Branch 20 not taken.
|
1 | EXPECT_EQ(engine->softSparkLimiter.getTargetSkipRatio(), TEST_LUA_SOFT_SPARK_SKIP); | |
43 |
2/6✓ Branch 5 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
|
1 | EXPECT_EQ(engine->hardSparkLimiter.getTargetSkipRatio(), TEST_LUA_HARD_SPARK_SKIP + TEST_TRACTION_CONTROL_IGNITION_SKIP); | |
44 | 1 | } | ||
45 | } | |||
46 |