Trigger decoding issues (60-2) #1488

unit test refactoring
This commit is contained in:
rusefi 2020-06-15 00:11:02 -04:00
parent f3344753e8
commit 9016df654c
1 changed files with 13 additions and 15 deletions

View File

@ -14,9 +14,6 @@
#include "pwm_generator_logic.h"
#include "unit_test_framework.h"
// this instance is used by some unit tests here which reference it directly
static EventQueue eq;
static int callbackCounter = 0;
static void callback(void *a) {
@ -25,23 +22,27 @@ static void callback(void *a) {
static int complexTestNow;
typedef struct {
struct TestPwm {
TestPwm(EventQueue *eventQueue) {
this->eventQueue = eventQueue;
}
scheduling_s s;
int period;
} TestPwm;
EventQueue *eventQueue;
};
static void complexCallback(TestPwm *testPwm) {
callbackCounter++;
eq.insertTask(&testPwm->s, complexTestNow + testPwm->period,
testPwm->eventQueue->insertTask(&testPwm->s, complexTestNow + testPwm->period,
{ complexCallback, testPwm });
}
static void testSignalExecutor2(void) {
print("*************************************** testSignalExecutor2\r\n");
eq.clear();
TestPwm p1;
TestPwm p2;
EventQueue eq;
TestPwm p1(&eq);
TestPwm p2(&eq);
p1.period = 2;
p2.period = 3;
@ -74,10 +75,8 @@ static void orderCallback(void *a) {
prevValue = value;
}
static void testSignalExecutor3(void) {
print("*************************************** testSignalExecutor3\r\n");
eq.clear();
TEST(misc, testSignalExecutor3) {
EventQueue eq;
scheduling_s s1;
scheduling_s s2;
@ -91,10 +90,9 @@ static void testSignalExecutor3(void) {
}
TEST(misc, testSignalExecutor) {
testSignalExecutor3();
print("*************************************** testSignalExecutor\r\n");
eq.clear();
EventQueue eq;
ASSERT_EQ(EMPTY_QUEUE, eq.getNextEventTime(0));
scheduling_s s1;
scheduling_s s2;