light refactoring
This commit is contained in:
parent
b4098fed2c
commit
2434f3a14b
|
@ -66,27 +66,6 @@ namespace {
|
||||||
setSatisfyActivationSwithSpeedAndTpsConditions(satifySwitchSpeedThresholdAndTpsConditions);
|
setSatisfyActivationSwithSpeedAndTpsConditions(satifySwitchSpeedThresholdAndTpsConditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setUpTestParameters() {
|
|
||||||
for (int loadIdx = 0; loadIdx < IGN_LOAD_COUNT; loadIdx++) {
|
|
||||||
config->ignitionTable[loadIdx][0] = TEST_IGNITION_650;
|
|
||||||
config->ignitionTable[loadIdx][1] = TEST_IGNITION_800;
|
|
||||||
config->ignitionTable[loadIdx][2] = TEST_IGNITION_1100;
|
|
||||||
config->ignitionTable[loadIdx][3] = TEST_IGNITION_1400;
|
|
||||||
config->ignitionTable[loadIdx][4] = TEST_IGNITION_1700;
|
|
||||||
config->ignitionTable[loadIdx][5] = TEST_IGNITION_2000;
|
|
||||||
config->ignitionTable[loadIdx][6] = TEST_IGNITION_2300;
|
|
||||||
config->ignitionTable[loadIdx][7] = TEST_IGNITION_2600;
|
|
||||||
config->ignitionTable[loadIdx][8] = TEST_IGNITION_2900;
|
|
||||||
config->ignitionTable[loadIdx][9] = TEST_IGNITION_3200;
|
|
||||||
config->ignitionTable[loadIdx][10] = TEST_IGNITION_3500;
|
|
||||||
config->ignitionTable[loadIdx][11] = TEST_IGNITION_3800;
|
|
||||||
config->ignitionTable[loadIdx][12] = TEST_IGNITION_4100;
|
|
||||||
config->ignitionTable[loadIdx][13] = TEST_IGNITION_4400;
|
|
||||||
config->ignitionTable[loadIdx][14] = TEST_IGNITION_4700;
|
|
||||||
config->ignitionTable[loadIdx][15] = TEST_IGNITION_7000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct IgnitionAngleAdvanceTestData {
|
struct IgnitionAngleAdvanceTestData {
|
||||||
const std::string context;
|
const std::string context;
|
||||||
const int rpm;
|
const int rpm;
|
||||||
|
@ -101,18 +80,16 @@ namespace {
|
||||||
const std::vector<IgnitionAngleAdvanceTestData> &testData
|
const std::vector<IgnitionAngleAdvanceTestData> &testData
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Checks that angle advance is not affected by `Launch Control` functionality: */
|
static const std::vector<IgnitionAngleAdvanceTestData> TEST_DATA_WITHOUT_LAUNCH_ANGLE_ADVANCE;
|
||||||
void checkAngleAdvanceWithoutLaunchControl(
|
private:
|
||||||
const std::optional<bool> launchControlEnabled = {},
|
void configureTestIgnitionTable();
|
||||||
const std::optional<bool> enableLaunchRetard = {},
|
|
||||||
const std::optional<bool> launchSmoothRetard = {}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void IgnitionAngleAdvanceTest::doTest(
|
void IgnitionAngleAdvanceTest::doTest(
|
||||||
const IgnitionAngleAdvanceTestConfig& config,
|
const IgnitionAngleAdvanceTestConfig& config,
|
||||||
const std::vector<IgnitionAngleAdvanceTestData> &testData
|
const std::vector<IgnitionAngleAdvanceTestData> &testData
|
||||||
) {
|
) {
|
||||||
|
configureTestIgnitionTable();
|
||||||
setUpTestConfig(config);
|
setUpTestConfig(config);
|
||||||
|
|
||||||
for (const IgnitionAngleAdvanceTestData &testDataItem: testData) {
|
for (const IgnitionAngleAdvanceTestData &testDataItem: testData) {
|
||||||
|
@ -125,21 +102,7 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IgnitionAngleAdvanceTest::checkAngleAdvanceWithoutLaunchControl(
|
const std::vector<IgnitionAngleAdvanceTestData> IgnitionAngleAdvanceTest::TEST_DATA_WITHOUT_LAUNCH_ANGLE_ADVANCE = {
|
||||||
const std::optional<bool> launchControlEnabled,
|
|
||||||
const std::optional<bool> enableLaunchRetard,
|
|
||||||
const std::optional<bool> launchSmoothRetard
|
|
||||||
) {
|
|
||||||
setUpTestParameters();
|
|
||||||
|
|
||||||
doTest(
|
|
||||||
/* config = */ {
|
|
||||||
/* launchControlEnabled = */ launchControlEnabled,
|
|
||||||
/* ignitionRetardEnable = */ enableLaunchRetard,
|
|
||||||
/* smoothRetardMode = */ launchSmoothRetard,
|
|
||||||
/* satifySwitchSpeedThresholdAndTpsConditions = */ true
|
|
||||||
},
|
|
||||||
/* testData = */ {
|
|
||||||
{ "TEST_IGNITION_650", 650, TEST_IGNITION_650 },
|
{ "TEST_IGNITION_650", 650, TEST_IGNITION_650 },
|
||||||
{ "TEST_IGNITION_800", 800, TEST_IGNITION_800 },
|
{ "TEST_IGNITION_800", 800, TEST_IGNITION_800 },
|
||||||
{ "TEST_IGNITION_1100", 1100, TEST_IGNITION_1100 },
|
{ "TEST_IGNITION_1100", 1100, TEST_IGNITION_1100 },
|
||||||
|
@ -161,17 +124,42 @@ namespace {
|
||||||
{ "TEST_IGNITION_4400", 4400, TEST_IGNITION_4400 },
|
{ "TEST_IGNITION_4400", 4400, TEST_IGNITION_4400 },
|
||||||
{ "TEST_IGNITION_4700", 4700, TEST_IGNITION_4700 },
|
{ "TEST_IGNITION_4700", 4700, TEST_IGNITION_4700 },
|
||||||
{ "TEST_IGNITION_7000", 7000, TEST_IGNITION_7000 }
|
{ "TEST_IGNITION_7000", 7000, TEST_IGNITION_7000 }
|
||||||
|
};
|
||||||
|
|
||||||
|
void IgnitionAngleAdvanceTest::configureTestIgnitionTable() {
|
||||||
|
for (int loadIdx = 0; loadIdx < IGN_LOAD_COUNT; loadIdx++) {
|
||||||
|
config->ignitionTable[loadIdx][0] = TEST_IGNITION_650;
|
||||||
|
config->ignitionTable[loadIdx][1] = TEST_IGNITION_800;
|
||||||
|
config->ignitionTable[loadIdx][2] = TEST_IGNITION_1100;
|
||||||
|
config->ignitionTable[loadIdx][3] = TEST_IGNITION_1400;
|
||||||
|
config->ignitionTable[loadIdx][4] = TEST_IGNITION_1700;
|
||||||
|
config->ignitionTable[loadIdx][5] = TEST_IGNITION_2000;
|
||||||
|
config->ignitionTable[loadIdx][6] = TEST_IGNITION_2300;
|
||||||
|
config->ignitionTable[loadIdx][7] = TEST_IGNITION_2600;
|
||||||
|
config->ignitionTable[loadIdx][8] = TEST_IGNITION_2900;
|
||||||
|
config->ignitionTable[loadIdx][9] = TEST_IGNITION_3200;
|
||||||
|
config->ignitionTable[loadIdx][10] = TEST_IGNITION_3500;
|
||||||
|
config->ignitionTable[loadIdx][11] = TEST_IGNITION_3800;
|
||||||
|
config->ignitionTable[loadIdx][12] = TEST_IGNITION_4100;
|
||||||
|
config->ignitionTable[loadIdx][13] = TEST_IGNITION_4400;
|
||||||
|
config->ignitionTable[loadIdx][14] = TEST_IGNITION_4700;
|
||||||
|
config->ignitionTable[loadIdx][15] = TEST_IGNITION_7000;
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IgnitionAngleAdvanceTest, withEnabledLaunchControlAndWithoutLaunchRetard) {
|
TEST_F(IgnitionAngleAdvanceTest, withEnabledLaunchControlAndWithoutLaunchRetard) {
|
||||||
checkAngleAdvanceWithoutLaunchControl();
|
doTest(
|
||||||
|
/* config = */ {
|
||||||
|
/* launchControlEnabled = */ {},
|
||||||
|
/* ignitionRetardEnable = */ {},
|
||||||
|
/* smoothRetardMode = */ {},
|
||||||
|
/* satifySwitchSpeedThresholdAndTpsConditions = */ true
|
||||||
|
},
|
||||||
|
/* testData = */ TEST_DATA_WITHOUT_LAUNCH_ANGLE_ADVANCE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IgnitionAngleAdvanceTest, withEnabledLaunchControlAndLaunchRetardWithoutSmooth) {
|
TEST_F(IgnitionAngleAdvanceTest, withEnabledLaunchControlAndLaunchRetardWithoutSmooth) {
|
||||||
setUpTestParameters();
|
|
||||||
|
|
||||||
doTest(
|
doTest(
|
||||||
/* config = */ {
|
/* config = */ {
|
||||||
/* launchControlEnabled = */ { true },
|
/* launchControlEnabled = */ { true },
|
||||||
|
@ -206,8 +194,6 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IgnitionAngleAdvanceTest, withEnabledLaunchControlAndLaunchRetardAndLaunchSmoothRetard) {
|
TEST_F(IgnitionAngleAdvanceTest, withEnabledLaunchControlAndLaunchRetardAndLaunchSmoothRetard) {
|
||||||
setUpTestParameters();
|
|
||||||
|
|
||||||
doTest(
|
doTest(
|
||||||
/* config = */ {
|
/* config = */ {
|
||||||
/* launchControlEnabled = */ { true },
|
/* launchControlEnabled = */ { true },
|
||||||
|
@ -258,18 +244,26 @@ namespace {
|
||||||
/* Tests for https://github.com/rusefi/rusefi/issues/6571: */
|
/* Tests for https://github.com/rusefi/rusefi/issues/6571: */
|
||||||
|
|
||||||
TEST_F(IgnitionAngleAdvanceTest, withDisabledLaunchControlAndLaunchRetardWithoutSmooth) {
|
TEST_F(IgnitionAngleAdvanceTest, withDisabledLaunchControlAndLaunchRetardWithoutSmooth) {
|
||||||
checkAngleAdvanceWithoutLaunchControl(
|
doTest(
|
||||||
|
/* config = */ {
|
||||||
/* launchControlEnabled = */ { false },
|
/* launchControlEnabled = */ { false },
|
||||||
/* enableLaunchRetard = */ {true},
|
/* ignitionRetardEnable = */ { true },
|
||||||
/* launchSmoothRetard = */ {false}
|
/* smoothRetardMode = */ { false },
|
||||||
|
/* satifySwitchSpeedThresholdAndTpsConditions = */ true
|
||||||
|
},
|
||||||
|
/* testData = */ TEST_DATA_WITHOUT_LAUNCH_ANGLE_ADVANCE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(IgnitionAngleAdvanceTest, withDisabledLaunchControlAndLaunchRetardAndSmooth) {
|
TEST_F(IgnitionAngleAdvanceTest, withDisabledLaunchControlAndLaunchRetardAndSmooth) {
|
||||||
checkAngleAdvanceWithoutLaunchControl(
|
doTest(
|
||||||
|
/* config = */ {
|
||||||
/* launchControlEnabled = */ { false },
|
/* launchControlEnabled = */ { false },
|
||||||
/* enableLaunchRetard = */ {true},
|
/* ignitionRetardEnable = */ { true },
|
||||||
/* launchSmoothRetard = */ {true}
|
/* smoothRetardMode = */ { true },
|
||||||
|
/* satifySwitchSpeedThresholdAndTpsConditions = */ true
|
||||||
|
},
|
||||||
|
/* testData = */ TEST_DATA_WITHOUT_LAUNCH_ANGLE_ADVANCE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue