Coil duty cycle ignores dwell #977

test-driven is the way to go
This commit is contained in:
rusefi 2019-10-15 05:16:30 -04:00
parent d0596388e6
commit 938d7739a6
2 changed files with 12 additions and 3 deletions

View File

@ -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);
}

View File

@ -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;
}