only:refactoring: extract part of functionality into `TestPersistentConfiguration` class
This commit is contained in:
parent
5c6ee81352
commit
5bce202067
|
@ -127,24 +127,26 @@ namespace {
|
|||
};
|
||||
|
||||
void IgnitionAngleAdvanceTest::configureTestIgnitionTable() {
|
||||
IgnitionTable testIgnitionTable;
|
||||
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;
|
||||
}
|
||||
testIgnitionTable[loadIdx][0] = TEST_IGNITION_650;
|
||||
testIgnitionTable[loadIdx][1] = TEST_IGNITION_800;
|
||||
testIgnitionTable[loadIdx][2] = TEST_IGNITION_1100;
|
||||
testIgnitionTable[loadIdx][3] = TEST_IGNITION_1400;
|
||||
testIgnitionTable[loadIdx][4] = TEST_IGNITION_1700;
|
||||
testIgnitionTable[loadIdx][5] = TEST_IGNITION_2000;
|
||||
testIgnitionTable[loadIdx][6] = TEST_IGNITION_2300;
|
||||
testIgnitionTable[loadIdx][7] = TEST_IGNITION_2600;
|
||||
testIgnitionTable[loadIdx][8] = TEST_IGNITION_2900;
|
||||
testIgnitionTable[loadIdx][9] = TEST_IGNITION_3200;
|
||||
testIgnitionTable[loadIdx][10] = TEST_IGNITION_3500;
|
||||
testIgnitionTable[loadIdx][11] = TEST_IGNITION_3800;
|
||||
testIgnitionTable[loadIdx][12] = TEST_IGNITION_4100;
|
||||
testIgnitionTable[loadIdx][13] = TEST_IGNITION_4400;
|
||||
testIgnitionTable[loadIdx][14] = TEST_IGNITION_4700;
|
||||
testIgnitionTable[loadIdx][15] = TEST_IGNITION_7000;
|
||||
};
|
||||
getTestPersistentConfiguration().setIgnitionTable(testIgnitionTable);
|
||||
}
|
||||
|
||||
TEST_F(IgnitionAngleAdvanceTest, withDisabledLaunchControlAndWithoutLaunchRetardWithSatisfiedLaunchConditions) {
|
||||
|
|
|
@ -50,6 +50,7 @@ TESTS_SRC_CPP = \
|
|||
tests/ignition_injection/test_three_cylinder.cpp \
|
||||
tests/util/test_base.cpp \
|
||||
tests/util/test_engine_configuration.cpp \
|
||||
tests/util/test_persistent_configuration.cpp \
|
||||
tests/util/test_engine_state.cpp \
|
||||
tests/ac/ac_test_base.cpp \
|
||||
tests/ac/ac_pressure_test.cpp \
|
||||
|
|
|
@ -18,6 +18,10 @@ TestEngineConfiguration& TestBase::getTestEngineConfiguration() {
|
|||
return TestEngineConfiguration::getInstance();
|
||||
}
|
||||
|
||||
TestPersistentConfiguration& TestBase::getTestPersistentConfiguration() {
|
||||
return TestPersistentConfiguration::getInstance();
|
||||
}
|
||||
|
||||
TestEngineState& TestBase::getTestEngineState() {
|
||||
return TestEngineState::getInstance();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "test_engine_configuration.h"
|
||||
#include "test_engine_state.h"
|
||||
#include "test_persistent_configuration.h"
|
||||
|
||||
class TestBase : public testing::Test {
|
||||
protected:
|
||||
|
@ -14,6 +15,7 @@ protected:
|
|||
|
||||
TestEngineConfiguration& getTestEngineConfiguration();
|
||||
TestEngineState& getTestEngineState();
|
||||
TestPersistentConfiguration& getTestPersistentConfiguration();
|
||||
|
||||
void periodicFastCallback();
|
||||
void periodicSlowCallback();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// Created by kifir on 11/5/24.
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "test_persistent_configuration.h"
|
||||
|
||||
TestPersistentConfiguration& TestPersistentConfiguration::getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
void TestPersistentConfiguration::setIgnitionTable(const IgnitionTable& ignitions) {
|
||||
for (int i = 0; i < IGN_LOAD_COUNT; i++) {
|
||||
for (int j = 0; j < IGN_RPM_COUNT; j++) {
|
||||
config->ignitionTable[i][j] = ignitions[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TestPersistentConfiguration TestPersistentConfiguration::instance;
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// Created by kifir on 11/5/24.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
using IgnitionTable = std::array<std::array<float, IGN_LOAD_COUNT>, IGN_RPM_COUNT>;
|
||||
|
||||
class TestPersistentConfiguration {
|
||||
public:
|
||||
static TestPersistentConfiguration& getInstance();
|
||||
|
||||
void setIgnitionTable(const IgnitionTable& ignitions);
|
||||
private:
|
||||
static TestPersistentConfiguration instance;
|
||||
};
|
Loading…
Reference in New Issue