From aeb5c8e8d6894ed4e9bf72c407749d300b1d6f23 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 23 Jul 2020 01:24:02 -0700 Subject: [PATCH] improve test --- unit_tests/tests/test_fuel_map.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/unit_tests/tests/test_fuel_map.cpp b/unit_tests/tests/test_fuel_map.cpp index 8d4d53c938..896960cc22 100644 --- a/unit_tests/tests/test_fuel_map.cpp +++ b/unit_tests/tests/test_fuel_map.cpp @@ -6,6 +6,7 @@ */ #include "fuel_math.h" +#include "maf_airmass.h" #include "trigger_structure.h" #include "allsensors.h" #include "engine_math.h" @@ -14,18 +15,25 @@ #include "efi_gpio.h" #include "advance_map.h" #include "sensor.h" +#include "mocks.h" + +using ::testing::FloatNear; TEST(misc, testMafFuelMath) { WITH_ENGINE_TEST_HELPER(FORD_ASPIRE_1996); - extern fuel_Map3D_t veMap; - veMap.setAll(75); - engineConfiguration->fuelAlgorithm = LM_REAL_MAF; engineConfiguration->injector.flow = 200; - setAfrMap(config->afrTable, 13); - auto airmass = getRealMafAirmass(200, 6000 PASS_ENGINE_PARAMETER_SUFFIX); + MockVp3d veTable; + // Ensure that the correct cell is read from the VE table + EXPECT_CALL(veTable, getValue(6000, FloatNear(70.9814f, EPS4D))) + .WillOnce(Return(75.0f)); + + MafAirmass dut(veTable); + INJECT_ENGINE_REFERENCE(&dut); + + auto airmass = dut.getAirmassImpl(200, 6000); // Check results EXPECT_NEAR(0.277777f * 0.75f, airmass.CylinderAirmass, EPS4D);