#35 unit tests
This commit is contained in:
parent
8e018681b9
commit
cd0b49fcfd
|
@ -304,9 +304,7 @@ void hipAdcCallback(adcsample_t adcValue) {
|
|||
|
||||
instance.setAngleWindowWidth(angleWindowWidth);
|
||||
|
||||
int prescalerIndex = engineConfiguration->hip9011PrescalerAndSDO;
|
||||
|
||||
instance.handleValue(GET_RPM(), prescalerIndex DEFINE_PARAM_SUFFIX(PASS_HIP_PARAMS));
|
||||
instance.handleValue(GET_RPM() DEFINE_PARAM_SUFFIX(PASS_HIP_PARAMS));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,8 @@ void HIP9011::setAngleWindowWidth(float angleWindowWidth) {
|
|||
prepareHip9011RpmLookup(angleWindowWidth);
|
||||
}
|
||||
|
||||
void HIP9011::handleValue(int rpm, int prescalerIndex DEFINE_PARAM_SUFFIX(DEFINE_HIP_PARAMS)) {
|
||||
void HIP9011::handleValue(int rpm DEFINE_PARAM_SUFFIX(DEFINE_HIP_PARAMS)) {
|
||||
int prescalerIndex = GET_CONFIG_VALUE(hip9011PrescalerAndSDO);
|
||||
int integratorIndex = getIntegrationIndexByRpm(rpm);
|
||||
int gainIndex = getHip9011GainIndex(FORWARD_HIP_PARAMS);
|
||||
int bandIndex = getBandIndex(FORWARD_HIP_PARAMS);
|
||||
|
|
|
@ -31,15 +31,18 @@ public:
|
|||
|
||||
#define PASS_HIP_PARAMS CONFIG(knockBandCustom), \
|
||||
CONFIG(cylinderBore), \
|
||||
CONFIG(hip9011Gain)
|
||||
CONFIG(hip9011Gain), \
|
||||
CONFIG(hip9011PrescalerAndSDO)
|
||||
|
||||
#define FORWARD_HIP_PARAMS knockBandCustom, \
|
||||
cylinderBore, \
|
||||
hip9011Gain
|
||||
hip9011Gain, \
|
||||
hip9011PrescalerAndSDO
|
||||
|
||||
#define DEFINE_HIP_PARAMS float knockBandCustom,\
|
||||
float cylinderBore, \
|
||||
float hip9011Gain
|
||||
float hip9011Gain, \
|
||||
int hip9011PrescalerAndSDO
|
||||
|
||||
#define GET_CONFIG_VALUE(x) x
|
||||
#define DEFINE_PARAM_SUFFIX(x) , x
|
||||
|
@ -52,7 +55,7 @@ public:
|
|||
int getIntegrationIndexByRpm(float rpm);
|
||||
void setStateAndCommand(unsigned char cmd);
|
||||
void setAngleWindowWidth(float angleWindowWidth);
|
||||
void handleValue(int rpm, int prescalerIndex DEFINE_PARAM_SUFFIX(DEFINE_HIP_PARAMS));
|
||||
void handleValue(int rpm DEFINE_PARAM_SUFFIX(DEFINE_HIP_PARAMS));
|
||||
|
||||
/**
|
||||
* band index is only send to HIP chip on startup
|
||||
|
|
|
@ -18,10 +18,10 @@ TEST(hip9011, lookup) {
|
|||
assertEqualsM2("240us 50 degree", 1105.2435, getRpmByAngleWindowAndTimeUs(240, 50), 0.1);
|
||||
assertEqualsM2("240us 50 degree", 6631.4619, getRpmByAngleWindowAndTimeUs(40, 50), 0.1);
|
||||
|
||||
EXPECT_EQ(0, getHip9011GainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/3));
|
||||
EXPECT_EQ(0, getHip9011GainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/2));
|
||||
EXPECT_EQ(47, getHip9011GainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/0.234));
|
||||
EXPECT_EQ(63, getHip9011GainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/0.000001));
|
||||
EXPECT_EQ(0, getHip9011GainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/3, 0));
|
||||
EXPECT_EQ(0, getHip9011GainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/2, 0));
|
||||
EXPECT_EQ(47, getHip9011GainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/0.234, 0));
|
||||
EXPECT_EQ(63, getHip9011GainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/0.000001, 0));
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ TEST(hip9011, rpmLookup) {
|
|||
|
||||
TEST(hip9011, band) {
|
||||
|
||||
EXPECT_FLOAT_EQ(3, getHIP9011Band(/* knockBandCustom*/3, /*cylinderBore*/76, /*hip9011Gain*/NAN));
|
||||
EXPECT_FLOAT_EQ(7.5389242, getHIP9011Band(/* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/NAN));
|
||||
EXPECT_FLOAT_EQ(3, getHIP9011Band(/* knockBandCustom*/3, /*cylinderBore*/76, /*hip9011Gain*/NAN, 0));
|
||||
EXPECT_FLOAT_EQ(7.5389242, getHIP9011Band(/* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/NAN, 0));
|
||||
|
||||
EXPECT_EQ(42, getBandIndex(/* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/NAN));
|
||||
EXPECT_EQ(42, getBandIndex(/* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/NAN, 0));
|
||||
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ TEST(hip9011, configurationCommands) {
|
|||
instance.prepareHip9011RpmLookup(50);
|
||||
|
||||
// want to invoke method with same parameters a few times
|
||||
#define PARAMETERS 600, _8MHZ_PRESCALER, /* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/1
|
||||
#define PARAMETERS 600, /* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/1, _8MHZ_PRESCALER
|
||||
|
||||
// Not making assumptions on the message send ...
|
||||
EXPECT_CALL(mock, sendSyncCommand(_)).Times(0);
|
||||
|
|
Loading…
Reference in New Issue