From ec6bde7c2670316e89f688eeab19d2c75001453a Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 28 Feb 2019 20:31:48 -0500 Subject: [PATCH] #699 more googletest to unit tests --- unit_tests/tests/test_fuel_map.cpp | 2 +- unit_tests/tests/test_maf2map.cpp | 2 -- unit_tests/tests/test_trigger_decoder.cpp | 10 +++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/unit_tests/tests/test_fuel_map.cpp b/unit_tests/tests/test_fuel_map.cpp index 3e7598b600..443221833f 100644 --- a/unit_tests/tests/test_fuel_map.cpp +++ b/unit_tests/tests/test_fuel_map.cpp @@ -68,7 +68,7 @@ TEST(misc, testFuelMap) { printf("*************************************************** getRunningFuel 1\r\n"); eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); float baseFuel = getBaseTableFuel(5, getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE)); - assertEqualsM("base fuel", 5.3679, getRunningFuel(baseFuel PASS_ENGINE_PARAMETER_SUFFIX)); + ASSERT_NEAR(5.3679, getRunningFuel(baseFuel PASS_ENGINE_PARAMETER_SUFFIX), EPS4D) << "base fuel"; printf("*************************************************** setting IAT table\r\n"); for (int i = 0; i < IAT_CURVE_SIZE; i++) { diff --git a/unit_tests/tests/test_maf2map.cpp b/unit_tests/tests/test_maf2map.cpp index f6e8856c81..8075bd835b 100644 --- a/unit_tests/tests/test_maf2map.cpp +++ b/unit_tests/tests/test_maf2map.cpp @@ -9,8 +9,6 @@ #include "maf2map.h" #define round_2d(x) efiRound(x, 0.01) -// todo: this should be improved to use relative 6 digit precision not just digits after decimal point -#define ASSERT_FLOAT_EQ(x, y) ASSERT_DOUBLE_EQ(round_2d(x), round_2d(y)) TEST(maf2map, util) { diff --git a/unit_tests/tests/test_trigger_decoder.cpp b/unit_tests/tests/test_trigger_decoder.cpp index 6ff268990c..e208387c38 100644 --- a/unit_tests/tests/test_trigger_decoder.cpp +++ b/unit_tests/tests/test_trigger_decoder.cpp @@ -179,13 +179,13 @@ TEST(misc, test1995FordInline6TriggerDecoder) { IgnitionEventList *ecl = &engine->ignitionEvents; ASSERT_EQ( 1, ecl->isReady) << "ford inline ignition events size"; ASSERT_EQ( 0, ecl->elements[0].dwellPosition.eventIndex) << "event index"; - assertEqualsM("angle offset#1", 7.8621, ecl->elements[0].dwellPosition.angleOffset); + ASSERT_NEAR(7.8621, ecl->elements[0].dwellPosition.angleOffset, EPS4D) << "angle offset#1"; ASSERT_EQ( 10, ecl->elements[5].dwellPosition.eventIndex) << "event index"; - assertEqualsM("angle offset#2", 7.8621, ecl->elements[5].dwellPosition.angleOffset); + ASSERT_NEAR(7.8621, ecl->elements[5].dwellPosition.angleOffset, EPS4D) << "angle offset#2"; - assertEqualsM("running dwell", 0.5, getSparkDwell(2000 PASS_ENGINE_PARAMETER_SUFFIX)); + ASSERT_FLOAT_EQ(0.5, getSparkDwell(2000 PASS_ENGINE_PARAMETER_SUFFIX)) << "running dwell"; } TEST(misc, testFordAspire) { @@ -709,7 +709,7 @@ void doTestFuelSchedulerBug299smallAndMedium(int startUpDelayMs) { setArrayValues(fuelMap.pointers[engineLoadIndex + 1], FUEL_RPM_COUNT, 25); engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); - assertEqualsM("fuel#2", 12.5, engine->injectionDuration); + ASSERT_FLOAT_EQ(12.5, engine->injectionDuration) << "fuel#2_0"; assertEqualsM("duty for maf=3", 62.5, getInjectorDutyCycle(GET_RPM() PASS_ENGINE_PARAMETER_SUFFIX)); ASSERT_EQ( 4, engine->executor.size()) << "qs#1"; @@ -993,7 +993,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) { setArrayValues(fuelMap.pointers[engineLoadIndex + 1], FUEL_RPM_COUNT, 35); engine->periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE); - assertEqualsM("Lfuel#2", 17.5, engine->injectionDuration); + ASSERT_FLOAT_EQ(17.5, engine->injectionDuration) << "Lfuel#2_1"; assertEqualsM("Lduty for maf=3", 87.5, getInjectorDutyCycle(GET_RPM() PASS_ENGINE_PARAMETER_SUFFIX));