tests
This commit is contained in:
parent
3c72fa93e4
commit
b961944790
|
@ -0,0 +1,41 @@
|
||||||
|
#include "engine_test_helper.h"
|
||||||
|
|
||||||
|
// sneaky...
|
||||||
|
#define protected public
|
||||||
|
#include "fuel_computer.h"
|
||||||
|
#include "mocks.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
using ::testing::FloatEq;
|
||||||
|
|
||||||
|
class MockFuelComputer : public FuelComputerBase {
|
||||||
|
public:
|
||||||
|
MOCK_METHOD(float, getStoichiometricRatio, (), (const, override));
|
||||||
|
MOCK_METHOD(float, getTargetLambda, (int rpm, float load), (const, override));
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(FuelComputer, getCycleFuel) {
|
||||||
|
WITH_ENGINE_TEST_HELPER(TEST_ENGINE);
|
||||||
|
|
||||||
|
MockFuelComputer dut;
|
||||||
|
INJECT_ENGINE_REFERENCE(&dut);
|
||||||
|
|
||||||
|
EXPECT_CALL(dut, getStoichiometricRatio())
|
||||||
|
.WillOnce(Return(3.0f));
|
||||||
|
EXPECT_CALL(dut, getTargetLambda(1000, FloatEq(0.8f)))
|
||||||
|
.WillOnce(Return(5.0f));
|
||||||
|
|
||||||
|
auto result = dut.getCycleFuel(7.0f, 1000, 0.8f);
|
||||||
|
EXPECT_FLOAT_EQ(result, 7.0f / (5 * 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(FuelComputer, LambdaLookup) {
|
||||||
|
MockVp3d afrTable;
|
||||||
|
FuelComputer dut(afrTable);
|
||||||
|
|
||||||
|
EXPECT_CALL(afrTable, getValue(1500, FloatEq(0.7f)))
|
||||||
|
.WillOnce(Return(14.7f));
|
||||||
|
|
||||||
|
EXPECT_FLOAT_EQ(dut.getTargetLambda(1500, 0.7f), 1.0f);
|
||||||
|
}
|
|
@ -78,7 +78,7 @@ TEST(AirmassModes, AlphaNFailedTps) {
|
||||||
EXPECT_EQ(result.CylinderAirmass, 0);
|
EXPECT_EQ(result.CylinderAirmass, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(misc, MafNormal) {
|
TEST(AirmassModes, MafNormal) {
|
||||||
WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996);
|
WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996);
|
||||||
engineConfiguration->fuelAlgorithm = LM_REAL_MAF;
|
engineConfiguration->fuelAlgorithm = LM_REAL_MAF;
|
||||||
engineConfiguration->injector.flow = 200;
|
engineConfiguration->injector.flow = 200;
|
||||||
|
|
|
@ -12,6 +12,7 @@ TESTS_SRC_CPP = \
|
||||||
tests/ignition_injection/test_multispark.cpp \
|
tests/ignition_injection/test_multispark.cpp \
|
||||||
tests/ignition_injection/test_ignition_scheduling.cpp \
|
tests/ignition_injection/test_ignition_scheduling.cpp \
|
||||||
tests/ignition_injection/test_fuelCut.cpp \
|
tests/ignition_injection/test_fuelCut.cpp \
|
||||||
|
tests/ignition_injection/test_fuel_computer.cpp \
|
||||||
tests/test_util.cpp \
|
tests/test_util.cpp \
|
||||||
tests/test_ion.cpp \
|
tests/test_ion.cpp \
|
||||||
tests/test_aux_valves.cpp \
|
tests/test_aux_valves.cpp \
|
||||||
|
|
Loading…
Reference in New Issue