parent
d68d6cc8ef
commit
160d8d7462
|
@ -14,9 +14,6 @@
|
||||||
#include "pwm_generator_logic.h"
|
#include "pwm_generator_logic.h"
|
||||||
#include "unit_test_framework.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 int callbackCounter = 0;
|
||||||
|
|
||||||
static void callback(void *a) {
|
static void callback(void *a) {
|
||||||
|
@ -25,23 +22,27 @@ static void callback(void *a) {
|
||||||
|
|
||||||
static int complexTestNow;
|
static int complexTestNow;
|
||||||
|
|
||||||
typedef struct {
|
struct TestPwm {
|
||||||
|
TestPwm(EventQueue *eventQueue) {
|
||||||
|
this->eventQueue = eventQueue;
|
||||||
|
}
|
||||||
scheduling_s s;
|
scheduling_s s;
|
||||||
int period;
|
int period;
|
||||||
} TestPwm;
|
EventQueue *eventQueue;
|
||||||
|
};
|
||||||
|
|
||||||
static void complexCallback(TestPwm *testPwm) {
|
static void complexCallback(TestPwm *testPwm) {
|
||||||
callbackCounter++;
|
callbackCounter++;
|
||||||
|
|
||||||
eq.insertTask(&testPwm->s, complexTestNow + testPwm->period,
|
testPwm->eventQueue->insertTask(&testPwm->s, complexTestNow + testPwm->period,
|
||||||
{ complexCallback, testPwm });
|
{ complexCallback, testPwm });
|
||||||
}
|
}
|
||||||
|
|
||||||
static void testSignalExecutor2(void) {
|
static void testSignalExecutor2(void) {
|
||||||
print("*************************************** testSignalExecutor2\r\n");
|
print("*************************************** testSignalExecutor2\r\n");
|
||||||
eq.clear();
|
EventQueue eq;
|
||||||
TestPwm p1;
|
TestPwm p1(&eq);
|
||||||
TestPwm p2;
|
TestPwm p2(&eq);
|
||||||
p1.period = 2;
|
p1.period = 2;
|
||||||
p2.period = 3;
|
p2.period = 3;
|
||||||
|
|
||||||
|
@ -74,10 +75,8 @@ static void orderCallback(void *a) {
|
||||||
prevValue = value;
|
prevValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(misc, testSignalExecutor3) {
|
||||||
static void testSignalExecutor3(void) {
|
EventQueue eq;
|
||||||
print("*************************************** testSignalExecutor3\r\n");
|
|
||||||
eq.clear();
|
|
||||||
|
|
||||||
scheduling_s s1;
|
scheduling_s s1;
|
||||||
scheduling_s s2;
|
scheduling_s s2;
|
||||||
|
@ -91,10 +90,9 @@ static void testSignalExecutor3(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(misc, testSignalExecutor) {
|
TEST(misc, testSignalExecutor) {
|
||||||
testSignalExecutor3();
|
|
||||||
print("*************************************** testSignalExecutor\r\n");
|
print("*************************************** testSignalExecutor\r\n");
|
||||||
|
|
||||||
eq.clear();
|
EventQueue eq;
|
||||||
ASSERT_EQ(EMPTY_QUEUE, eq.getNextEventTime(0));
|
ASSERT_EQ(EMPTY_QUEUE, eq.getNextEventTime(0));
|
||||||
scheduling_s s1;
|
scheduling_s s1;
|
||||||
scheduling_s s2;
|
scheduling_s s2;
|
||||||
|
|
Loading…
Reference in New Issue