diff --git a/unit_tests/tests/test_trigger_decoder.cpp b/unit_tests/tests/test_trigger_decoder.cpp index 44119a1618..9e825f14fa 100644 --- a/unit_tests/tests/test_trigger_decoder.cpp +++ b/unit_tests/tests/test_trigger_decoder.cpp @@ -204,11 +204,16 @@ TEST(misc, testFordAspire) { engine->rpmCalculator.setRpmValue(200 PASS_ENGINE_PARAMETER_SUFFIX); assertEqualsM("cranking dwell", 54.166670, getSparkDwell(200 PASS_ENGINE_PARAMETER_SUFFIX)); - engine->rpmCalculator.setRpmValue(2000 PASS_ENGINE_PARAMETER_SUFFIX); - ASSERT_EQ( 4, getSparkDwell(2000 PASS_ENGINE_PARAMETER_SUFFIX)) << "running dwell"; + int rpm = 2000; + engine->rpmCalculator.setRpmValue(rpm PASS_ENGINE_PARAMETER_SUFFIX); + ASSERT_EQ( 4, getSparkDwell(rpm PASS_ENGINE_PARAMETER_SUFFIX)) << "running dwell"; + + ASSERT_NEAR( 6.666666666, getCoilDutyCycle(rpm PASS_ENGINE_PARAMETER_SUFFIX), 0.0001); + engine->rpmCalculator.setRpmValue(6000 PASS_ENGINE_PARAMETER_SUFFIX); assertEqualsM("higher rpm dwell", 3.25, getSparkDwell(6000 PASS_ENGINE_PARAMETER_SUFFIX)); + } static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty) { @@ -553,7 +558,7 @@ TEST(misc, testTriggerDecoder) { extern fuel_Map3D_t fuelMap; static void assertInjectionEvent(const char *msg, InjectionEvent *ev, int injectorIndex, int eventIndex, angle_t angleOffset) { - assertEqualsM4(msg, "inj index", injectorIndex, ev->outputs[0]->injectorIndex); + ASSERT_EQ(injectorIndex, ev->outputs[0]->injectorIndex) << msg << "inj index"; assertEqualsM4(msg, " event index", eventIndex, ev->injectionStart.triggerEventIndex); assertEqualsM4(msg, " event offset", angleOffset, ev->injectionStart.angleOffsetFromTriggerEvent); } diff --git a/unit_tests/unit_test_framework.cpp b/unit_tests/unit_test_framework.cpp index 2af3ce0f68..a1ea3b3e73 100644 --- a/unit_tests/unit_test_framework.cpp +++ b/unit_tests/unit_test_framework.cpp @@ -9,6 +9,10 @@ #include "global.h" #include "unit_test_framework.h" +/** + * ASSERT_xxx macro could only be used from inside 'void' methods - for cases where non-void methods are asserting, these + * wrapper functions are still useful. + */ void assertEqualsM2(const char *msg, float expected, float actual, float eps) { ASSERT_NEAR(expected, actual, eps) << msg; }