testing API improvement (?)

This commit is contained in:
rusefi 2019-01-21 22:34:17 -05:00
parent d15399bba4
commit 358af4ff89
3 changed files with 9 additions and 2 deletions

View File

@ -130,6 +130,10 @@ int EngineTestHelper::executeActions() {
return engine.executor.executeAll(timeNowUs);
}
void EngineTestHelper::moveTimeForwardMs(float deltaTimeMs) {
moveTimeForwardUs(MS2US(deltaTimeMs));
}
void EngineTestHelper::moveTimeForwardUs(int deltaTimeUs) {
timeNowUs += deltaTimeUs;
}
@ -181,6 +185,7 @@ void EngineTestHelper::applyTriggerShape() {
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
}
// todo: open question if this is worth a helper method or should be inlined?
void EngineTestHelper::assertRpm(int expectedRpm, const char *msg) {
Engine *engine = &this->engine;
EXPAND_Engine

View File

@ -48,9 +48,11 @@ public:
void assertEvent(TestExecutor *executor, const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param);
void assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex);
void assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex);
// todo: open question if this is worth a helper method or should be inlined?
void assertRpm(int expectedRpm, const char *msg);
int executeActions();
void moveTimeForwardMs(float deltaTimeMs);
void moveTimeForwardUs(int deltaTimeUs);
efitimeus_t getTimeNowUs(void);

View File

@ -324,7 +324,7 @@ TEST(misc, testRpmCalculator) {
ASSERT_EQ(engine->triggerCentral.triggerState.shaft_is_synchronized, 1);
eth.moveTimeForwardUs(MS2US(5)); // 5ms
eth.moveTimeForwardMs(5 /*ms*/);
int start = eth.getTimeNowUs();
ASSERT_EQ( 485000, start) << "start value";
@ -633,7 +633,7 @@ static void setTestBug299(EngineTestHelper *eth) {
/**
* Trigger up again
*/
eth->moveTimeForwardUs(MS2US(20));
eth->moveTimeForwardMs(20 /*ms*/);
eth->assertInjectorUpEvent("22@0", 0, MS2US(-11.5), 0);
eth->assertInjectorDownEvent("22@1", 1, MS2US(-10), 0);
eth->assertInjectorUpEvent("22@2", 2, MS2US(-1.5), 1);