migrating to googletest
This commit is contained in:
parent
6c62f2e25f
commit
9d1fc30857
|
@ -105,9 +105,9 @@ TEST(misc, testSetTableValue) {
|
|||
ASSERT_EQ(1, config.cltFuelCorr[0]);
|
||||
|
||||
setCurveValue(config.cltFuelCorrBins, config.cltFuelCorr, CLT_CURVE_SIZE, -40, 1.5);
|
||||
assertEquals(1.5, config.cltFuelCorr[0]);
|
||||
ASSERT_FLOAT_EQ(1.5, config.cltFuelCorr[0]);
|
||||
|
||||
setCurveValue(config.cltFuelCorrBins, config.cltFuelCorr, CLT_CURVE_SIZE, -50, 1.4);
|
||||
assertEquals(1.4, config.cltFuelCorr[0]);
|
||||
ASSERT_FLOAT_EQ(1.4, config.cltFuelCorr[0]);
|
||||
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ TEST(misc, testEngineMath) {
|
|||
assertEqualsM("600 RPM", 50, getOneDegreeTimeMs(600) * 180);
|
||||
assertEqualsM("6000 RPM", 5, getOneDegreeTimeMs(6000) * 180);
|
||||
|
||||
assertEquals(312.5, getTCharge(1000, 0, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
assertEquals(313.5833, getTCharge(1000, 50, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
assertEquals(314.6667, getTCharge(1000, 100, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(312.5, getTCharge(1000, 0, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(313.5833, getTCharge(1000, 50, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(314.6667, getTCharge(1000, 100, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
|
||||
|
||||
assertEquals(312.5, getTCharge(4000, 0, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
assertEquals(320.0833, getTCharge(4000, 50, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
assertEquals(327.6667, getTCharge(4000, 100, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(312.5, getTCharge(4000, 0, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(320.0833, getTCharge(4000, 50, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(327.6667, getTCharge(4000, 100, 300, 350 PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
|
||||
// test Air Interpolation mode
|
||||
engineConfiguration->tChargeMode = TCHARGE_MODE_AIR_INTERP;
|
||||
|
@ -52,10 +52,10 @@ TEST(misc, testEngineMath) {
|
|||
engineConfiguration->tChargeAirFlowMax = 153.6f;
|
||||
// calc. some airMass given the engine displacement=1.839 and 4 cylinders (FORD_ESCORT_GT)
|
||||
engine->engineState.airMass = getCylinderAirMass(engineConfiguration, /*VE*/1.0f, /*MAP*/100.0f, /*tChargeK*/273.15f + 20.0f);
|
||||
assertEquals(0.5464f, engine->engineState.airMass);
|
||||
ASSERT_NEAR(0.5464f, engine->engineState.airMass, EPS4D);
|
||||
// calc. airFlow using airMass, and find tCharge
|
||||
assertEquals(59.1175f, getTCharge(/*RPM*/1000, /*TPS*/0, /*CLT*/90.0f, /*IAT*/20.0f PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
assertEquals(65.5625f/*kg/h*/, engine->engineState.airFlow);
|
||||
ASSERT_FLOAT_EQ(59.1175f, getTCharge(/*RPM*/1000, /*TPS*/0, /*CLT*/90.0f, /*IAT*/20.0f PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(65.5625f/*kg/h*/, engine->engineState.airFlow);
|
||||
}
|
||||
|
||||
TEST(misc, testIgnitionMapGenerator) {
|
||||
|
@ -74,8 +74,8 @@ TEST(misc, testIgnitionMapGenerator) {
|
|||
ASSERT_EQ(7000, rpmBin[15]);
|
||||
|
||||
|
||||
assertEquals(22.0, getTopAdvanceForBore(CS_SWIRL_TUMBLE, 89, 9, 101.6));
|
||||
assertEquals(32.2, getTopAdvanceForBore(CS_SWIRL_TUMBLE, 89, 9, 145));
|
||||
ASSERT_FLOAT_EQ(22.0, getTopAdvanceForBore(CS_SWIRL_TUMBLE, 89, 9, 101.6));
|
||||
ASSERT_FLOAT_EQ(32.2, getTopAdvanceForBore(CS_SWIRL_TUMBLE, 89, 9, 145));
|
||||
|
||||
assertEqualsM2("100@6000", 36.0, getInitialAdvance(6000, 100, 36), 0.1);
|
||||
assertEqualsM2("100@600", 9.9, getInitialAdvance(600, 100, 36), 0.2);
|
||||
|
|
|
@ -134,7 +134,7 @@ static void confgiureFordAspireTriggerShape(TriggerShape * s) {
|
|||
s->addEvent720(657.03, T_SECONDARY, TV_FALL);
|
||||
s->addEvent720(720, T_PRIMARY, TV_FALL);
|
||||
|
||||
assertEquals(53.747 / 720, s->wave.getSwitchTime(0));
|
||||
ASSERT_FLOAT_EQ(53.747 / 720, s->wave.getSwitchTime(0));
|
||||
assertEqualsM("@0", 1, s->wave.getChannelState(1, 0));
|
||||
assertEqualsM("@0", 1, s->wave.getChannelState(1, 0));
|
||||
|
||||
|
@ -150,8 +150,8 @@ static void confgiureFordAspireTriggerShape(TriggerShape * s) {
|
|||
assertEqualsM("@4", 1, s->wave.getChannelState(0, 4));
|
||||
assertEqualsM("@5", 1, s->wave.getChannelState(1, 5));
|
||||
assertEqualsM("@8", 0, s->wave.getChannelState(1, 8));
|
||||
assertEquals(121.90 / 720, s->wave.getSwitchTime(1));
|
||||
assertEquals(657.03 / 720, s->wave.getSwitchTime(8));
|
||||
ASSERT_FLOAT_EQ(121.90 / 720, s->wave.getSwitchTime(1));
|
||||
ASSERT_FLOAT_EQ(657.03 / 720, s->wave.getSwitchTime(8));
|
||||
|
||||
assertEqualsM("expecting 0", 0, s->wave.findAngleMatch(53.747 / 720.0, s->getSize()));
|
||||
assertEqualsM("expecting not found", -1, s->wave.findAngleMatch(53 / 720.0, s->getSize()));
|
||||
|
@ -186,32 +186,32 @@ TEST(misc, testAngleResolver) {
|
|||
printf("*************************************************** testAngleResolver 0\r\n");
|
||||
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -122, engineConfiguration->globalTriggerAngleOffset));
|
||||
assertEqualsM("eventIndex@0", 2, injectionStart.eventIndex);
|
||||
assertEquals(0.24, injectionStart.angleOffset);
|
||||
ASSERT_NEAR(0.24, injectionStart.angleOffset, EPS5D);
|
||||
|
||||
printf("*************************************************** testAngleResolver 0.1\r\n");
|
||||
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -80, engineConfiguration->globalTriggerAngleOffset));
|
||||
assertEqualsM("eventIndex@0", 2, injectionStart.eventIndex);
|
||||
assertEquals(42.24, injectionStart.angleOffset);
|
||||
ASSERT_FLOAT_EQ(42.24, injectionStart.angleOffset);
|
||||
|
||||
printf("*************************************************** testAngleResolver 0.2\r\n");
|
||||
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -54, engineConfiguration->globalTriggerAngleOffset));
|
||||
assertEqualsM("eventIndex@0", 2, injectionStart.eventIndex);
|
||||
assertEquals(68.2400, injectionStart.angleOffset);
|
||||
ASSERT_FLOAT_EQ(68.2400, injectionStart.angleOffset);
|
||||
|
||||
printf("*************************************************** testAngleResolver 0.3\r\n");
|
||||
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -53, engineConfiguration->globalTriggerAngleOffset));
|
||||
ASSERT_EQ(2, injectionStart.eventIndex);
|
||||
assertEquals(69.24, injectionStart.angleOffset);
|
||||
ASSERT_FLOAT_EQ(69.24, injectionStart.angleOffset);
|
||||
|
||||
printf("*************************************************** testAngleResolver 1\r\n");
|
||||
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, 0, engineConfiguration->globalTriggerAngleOffset));
|
||||
ASSERT_EQ(2, injectionStart.eventIndex);
|
||||
assertEquals(122.24, injectionStart.angleOffset);
|
||||
ASSERT_FLOAT_EQ(122.24, injectionStart.angleOffset);
|
||||
|
||||
printf("*************************************************** testAngleResolver 2\r\n");
|
||||
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, 56, engineConfiguration->globalTriggerAngleOffset));
|
||||
ASSERT_EQ(2, injectionStart.eventIndex);
|
||||
assertEquals(178.24, injectionStart.angleOffset);
|
||||
ASSERT_FLOAT_EQ(178.24, injectionStart.angleOffset);
|
||||
|
||||
TriggerShape t;
|
||||
confgiureFordAspireTriggerShape(&t);
|
||||
|
|
|
@ -20,11 +20,11 @@ TEST(sensors, mapDecoding) {
|
|||
s.type = MT_DENSO183;
|
||||
|
||||
assertEqualsM("denso 0 volts", -6.64, decodePressure(0, &s PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
assertEquals(31.244, decodePressure(1, &s PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(31.244, decodePressure(1, &s PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
|
||||
s.type = MT_MPX4250;
|
||||
assertEqualsM("MPX_4250 0 volts", 8, decodePressure(0, &s PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
assertEquals(58.4, decodePressure(1, &s PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
ASSERT_FLOAT_EQ(58.4, decodePressure(1, &s PASS_ENGINE_PARAMETER_SUFFIX));
|
||||
}
|
||||
|
||||
TEST(sensors, tps) {
|
||||
|
@ -57,18 +57,18 @@ TEST(sensors, testTpsRateOfChange) {
|
|||
// assertEquals(25, getTpsRateOfChange());
|
||||
}
|
||||
|
||||
TEST(sensors, tm) {
|
||||
TEST(sensors, thermistors) {
|
||||
|
||||
ThermistorMath tm;
|
||||
{
|
||||
setThermistorConfiguration(&tc, 32, 9500, 75, 2100, 120, 1000);
|
||||
tm.setConfig(&tc.config);
|
||||
float t = tm.getKelvinTemperatureByResistance(2100);
|
||||
assertEquals(75 + KELV, t);
|
||||
ASSERT_FLOAT_EQ(75 + KELV, t);
|
||||
|
||||
assertEquals(-0.003, tm.s_h_a);
|
||||
assertEquals(0.001, tm.s_h_b);
|
||||
assertEquals(0.0, tm.s_h_c);
|
||||
ASSERT_NEAR(-0.003, tm.s_h_a, EPS4D);
|
||||
ASSERT_NEAR(0.001, tm.s_h_b, EPS4D);
|
||||
ASSERT_NEAR(0.0, tm.s_h_c, EPS5D);
|
||||
|
||||
}
|
||||
|
||||
|
@ -78,11 +78,10 @@ TEST(sensors, tm) {
|
|||
tm.setConfig(&tc.config);
|
||||
|
||||
float t = tm.getKelvinTemperatureByResistance(38000);
|
||||
assertEquals(-2.7983, t - KELV);
|
||||
ASSERT_NEAR(-2.7983, t - KELV, EPS4D);
|
||||
|
||||
assertEqualsM("A", 0.0009, tm.s_h_a);
|
||||
assertEqualsM("B", 0.0003, tm.s_h_b);
|
||||
assertEquals(0.0, tm.s_h_c);
|
||||
ASSERT_NEAR(0.0, tm.s_h_c, EPS4D);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ TEST(big, testSpeedDensity) {
|
|||
|
||||
float airMass = getCylinderAirMass(engineConfiguration, 0.92, 98, 293.16);
|
||||
|
||||
assertEquals(0.9371, airMass);
|
||||
ASSERT_FLOAT_EQ(0.9371106624, airMass);
|
||||
|
||||
// 0.01414 sec or 14.14 ms
|
||||
assertEquals(0.01414, sdMath(engineConfiguration, airMass, 12.5));
|
||||
ASSERT_FLOAT_EQ(0.014137065038, sdMath(engineConfiguration, airMass, 12.5));
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#define EPS1D 0.1
|
||||
#define EPS2D 0.01
|
||||
#define EPS3D 0.001
|
||||
#define EPS4D 0.0001
|
||||
#define EPS5D 0.00001
|
||||
|
||||
void assertEqualsM2(const char *msg, float expected, float actual, float EPS);
|
||||
void assertEqualsM(const char *msg, float expected, float actual);
|
||||
void assertEqualsLM(const char *msg, long expected, long actual);
|
||||
|
|
Loading…
Reference in New Issue