From f801345ec70fcb1dd55c57b875b1c459941b5b1e Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 4 Mar 2018 22:00:32 -0500 Subject: [PATCH] refactoring --- unit_tests/main.h | 13 +------------ unit_tests/test_trigger_decoder.cpp | 7 +------ unit_tests/unit_test_framework.h | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/unit_tests/main.h b/unit_tests/main.h index d81bf46d8c..e3001ea031 100644 --- a/unit_tests/main.h +++ b/unit_tests/main.h @@ -11,6 +11,7 @@ #include #include +#include "unit_test_framework.h" #include "global.h" #include "error_handling.h" @@ -43,18 +44,6 @@ void print(const char *fmt, ...); #define chDbgCheck(x, y) chDbgAssert(x, y, NULL) -void assertEqualsM2(const char *msg, float expected, float actual, float EPS); -void assertEqualsM(const char *msg, float expected, float actual); -void assertEqualsLM(const char *msg, long expected, long actual); -void assertEqualsM4(const char *prefix, const char *msg, float expected, float actual); -void assertEqualsM5(const char *prefix, const char *message, float expected, float actual, float EPS); -void assertEquals(float expected, float actual); -void assertTrue(float actual); -void assertTrueM(const char *msg, float actual); -void assertFalse(float actual); -void assertFalseM(const char *msg, float actual); - - #define systicks2ms(x) (0) #ifdef __cplusplus diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index d5b066f570..27d64b2950 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -291,11 +291,6 @@ static void assertREqualsM(const char *msg, void *expected, void *actual) { extern bool_t debugSignalExecutor; extern EnginePins enginePins; -// todo: move method body here after merge -void assertEvent(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); - void testRpmCalculator(void) { printf("*************************************************** testRpmCalculator\r\n"); timeNowUs = 0; @@ -592,7 +587,7 @@ extern fuel_Map3D_t fuelMap; void assertEvent(const char *msg, int index, void *callback, efitime_t start, efitime_t momentX, long param) { assertTrueM(msg, schedulingQueue.size() > index); scheduling_s *ev = schedulingQueue.getForUnitText(index); - assertEqualsM4(msg, "up/down", (void*)ev->callback == (void*) callback, 1); + assertEqualsM4(msg, " up/down", (void*)ev->callback == (void*) callback, 1); assertEqualsM(msg, momentX, ev->momentX - start); InjectionSignalPair *pair = (InjectionSignalPair *)ev->param; assertEqualsLM(msg, param, (long)pair->outputs[0]); diff --git a/unit_tests/unit_test_framework.h b/unit_tests/unit_test_framework.h index ba13e6da05..44e3a222c2 100644 --- a/unit_tests/unit_test_framework.h +++ b/unit_tests/unit_test_framework.h @@ -8,8 +8,21 @@ #ifndef UNIT_TEST_FRAMEWORK_H_ #define UNIT_TEST_FRAMEWORK_H_ +#include "efitime.h" +void assertEqualsM2(const char *msg, float expected, float actual, float EPS); +void assertEqualsM(const char *msg, float expected, float actual); +void assertEqualsLM(const char *msg, long expected, long actual); +void assertEqualsM4(const char *prefix, const char *msg, float expected, float actual); +void assertEqualsM5(const char *prefix, const char *message, float expected, float actual, float EPS); +void assertEquals(float expected, float actual); +void assertTrue(float actual); +void assertTrueM(const char *msg, float actual); +void assertFalse(float actual); +void assertFalseM(const char *msg, float actual); - +void assertEvent(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); #endif /* UNIT_TEST_FRAMEWORK_H_ */