migrating to google test
This commit is contained in:
parent
4210754280
commit
f8a3d900dc
|
@ -32,8 +32,8 @@ static void assertNextEvent(const char *msg, int expectedPinState, TestExecutor
|
|||
timeNowUs = expectedTimeOfNextEvent;
|
||||
|
||||
// execute pending actions and assert that only one action was executed
|
||||
assertEqualsM5(msg, " executed", 1, executor->executeAll(timeNowUs), 0);
|
||||
assertEqualsM5(msg, " pin state", expectedPinState, pinValue, 0);
|
||||
ASSERT_NEAR(1, executor->executeAll(timeNowUs), 0) << msg << " executed";
|
||||
ASSERT_NEAR(expectedPinState, pinValue, 0) << msg << " pin state";
|
||||
|
||||
// assert that we have one new action in queue
|
||||
ASSERT_EQ( 1, executor->size()) << "PWM_test: queue.size";
|
||||
|
|
|
@ -223,8 +223,8 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo
|
|||
|
||||
assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerShapeSynchPointIndex());
|
||||
|
||||
assertEqualsM5(msg, " channel1duty", channel1duty, t->expectedDutyCycle[0], 0.0001);
|
||||
assertEqualsM5(msg, " channel2duty", channel2duty, t->expectedDutyCycle[1], 0.0001);
|
||||
ASSERT_NEAR(channel1duty, t->expectedDutyCycle[0], 0.0001) << msg << " channel1duty";
|
||||
ASSERT_NEAR(channel2duty, t->expectedDutyCycle[1], 0.0001) << msg << " channel2duty";
|
||||
}
|
||||
|
||||
static void testTriggerDecoder3(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty, float expectedGap) {
|
||||
|
|
|
@ -7,38 +7,18 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "global.h"
|
||||
|
||||
void assertEqualsM5(const char *prefix, const char *message, float expected, float actual, float EPS) {
|
||||
char msg[100];
|
||||
strcpy(msg, prefix);
|
||||
strcat(msg, message);
|
||||
if (cisnan(actual) && !cisnan(expected)) {
|
||||
printf("Assert failed: %s %.4f while expected %.4f\r\n", msg, actual, expected);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
float delta = absF(actual - expected);
|
||||
if (delta > EPS) {
|
||||
printf("delta: %.7f\r\n", delta);
|
||||
printf("Unexpected: %s %.4f while expected %.4f\r\n", msg, actual, expected);
|
||||
exit(-1);
|
||||
}
|
||||
printf("Validated %s: %f\r\n", msg, expected);
|
||||
}
|
||||
#include "unit_test_framework.h"
|
||||
|
||||
void assertEqualsM2(const char *msg, float expected, float actual, float eps) {
|
||||
assertEqualsM5("", msg, expected, actual, eps);
|
||||
ASSERT_NEAR(expected, actual, eps) << msg;
|
||||
}
|
||||
|
||||
void assertEqualsM4(const char *prefix, const char *msg, float expected, float actual) {
|
||||
assertEqualsM5(prefix, msg, expected, actual, 0.00001);
|
||||
ASSERT_NEAR(expected, actual, 0.00001) << prefix << msg;
|
||||
}
|
||||
|
||||
void assertEqualsLM(const char *msg, long expected, long actual) {
|
||||
if (expected != actual) {
|
||||
printf("Assert failed: %s %d while expected %d\r\n", msg, actual, expected);
|
||||
exit(-1);
|
||||
}
|
||||
ASSERT_EQ(expected, actual) << msg;
|
||||
}
|
||||
|
||||
void assertEqualsM(const char *msg, float expected, float actual) {
|
||||
|
|
|
@ -23,6 +23,5 @@ 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);
|
||||
|
||||
#endif /* UNIT_TEST_FRAMEWORK_H_ */
|
||||
|
|
Loading…
Reference in New Issue