migrating to googletest

This commit is contained in:
rusefi 2019-01-14 19:02:36 -05:00
parent 481fa81071
commit f18349cd68
4 changed files with 18 additions and 23 deletions

View File

@ -66,7 +66,7 @@ static void testPidAutoZigZagStable() {
for (; mockTimeMs <= 10 + startMockMs; mockTimeMs++) {
at.input = zigZagValue(mockTimeMs);
bool result = at.Runtime(&logging);
assertFalseM("should be false#1", result);
ASSERT_FALSE(result) << "should be false#1";
}
// assertEqualsLM("min@11", 0, at.absMin);
@ -76,14 +76,14 @@ static void testPidAutoZigZagStable() {
for (; mockTimeMs <= 21; mockTimeMs++) {
at.input = zigZagValue(mockTimeMs);
bool result = at.Runtime(&logging);
assertFalseM("should be false#2", result);
ASSERT_FALSE(result) << "should be false#2";
}
ASSERT_EQ( 0, at.peakCount) << "peakCount@21";
for (; mockTimeMs <= 41; mockTimeMs++) {
at.input = zigZagValue(mockTimeMs);
bool result = at.Runtime(&logging);
assertFalseM("should be false#2_2", result);
ASSERT_FALSE(result) << "should be false#2_2";
}
ASSERT_EQ( 2, at.peakCount) << "peakCount@41";
// ASSERT_EQ( 1, cisnan(at.Pu)) << "Pu@41";
@ -91,7 +91,7 @@ static void testPidAutoZigZagStable() {
for (; mockTimeMs <= 60; mockTimeMs++) {
at.input = zigZagValue(mockTimeMs);
bool result = at.Runtime(&logging);
assertFalseM("should be false#4", result);
ASSERT_FALSE(result) << "should be false#4";
}
ASSERT_EQ( 4, at.peakCount) << "peakCount@60";
//assertEqualsM("Pu@60", 0.02, at.Pu);
@ -102,7 +102,7 @@ static void testPidAutoZigZagStable() {
at.input = zigZagValue(mockTimeMs);
bool result = at.Runtime(&logging);
assertFalseM("should be false#4", result);
ASSERT_FALSE(result) << "should be false#4";
}
at.input = zigZagValue(mockTimeMs);
@ -136,7 +136,7 @@ static void testPidAutoZigZagGrowingOsc() {
for (; mockTimeMs < CYCLE + startMockMs; mockTimeMs++) {
at.input = zigZagValue(mockTimeMs);
bool result = at.Runtime(&logging);
assertFalseM("should be false#4", result);
ASSERT_FALSE(result) << "should be false#4";
}
oscRange *= 1.5;
}
@ -146,7 +146,7 @@ static void testPidAutoZigZagGrowingOsc() {
// printf("loop2=%d\r\n", mockTimeMs);
// at.input = zigZagValue(mockTimeMs);
// bool result = at.Runtime(&logging);
// assertFalseM("should be false#5", result);
// ASSERT_FALSE(result) << "should be false#5";
// }
at.input = zigZagValue(mockTimeMs);
@ -173,7 +173,7 @@ TEST(pidAutoTune, zeroLine) {
for (; mockTimeMs < CYCLE + startMockMs; mockTimeMs++) {
at.input = 0;
bool result = at.Runtime(&logging);
assertFalseM("should be false#4", result);
ASSERT_FALSE(result) << "should be false#4";
}
}
// nothing happens in this test since we do not allow time play a role

View File

@ -70,17 +70,17 @@ static void testDodgeNeonDecoder(void) {
TriggerState state;
assertFalseM("1 shaft_is_synchronized", state.shaft_is_synchronized);
ASSERT_FALSE(state.shaft_is_synchronized) << "1 shaft_is_synchronized";
// int r = 0;
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60);
// assertFalseM("2 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
// ASSERT_FALSE(state.shaft_is_synchronized) << "2 shaft_is_synchronized"; // still no synchronization
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210);
// assertFalseM("3 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
// ASSERT_FALSE(state.shaft_is_synchronized) << "3 shaft_is_synchronized"; // still no synchronization
//
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420);
// assertFalseM("4 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
// ASSERT_FALSE(state.shaft_is_synchronized) << "4 shaft_is_synchronized"; // still no synchronization
//
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630);
// ASSERT_FALSE(state.shaft_is_synchronized); // still no synchronization
@ -122,10 +122,10 @@ TEST(misc, testSomethingWeird) {
TriggerState *sta = &state_;
assertFalseM("shaft_is_synchronized", sta->shaft_is_synchronized);
ASSERT_FALSE(sta->shaft_is_synchronized) << "shaft_is_synchronized";
int r = 10;
sta->decodeTriggerEvent(SHAFT_PRIMARY_FALLING, r PASS_ENGINE_PARAMETER_SUFFIX);
assertFalseM("shaft_is_synchronized", sta->shaft_is_synchronized); // still no synchronization
ASSERT_FALSE(sta->shaft_is_synchronized) << "shaft_is_synchronized"; // still no synchronization
sta->decodeTriggerEvent(SHAFT_PRIMARY_RISING, ++r PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_TRUE(sta->shaft_is_synchronized); // first signal rise synchronize
ASSERT_EQ(0, sta->getCurrentIndex());
@ -226,7 +226,7 @@ void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPointInde
TriggerShape *t = &ENGINE(triggerCentral.triggerShape);
assertFalseM("isError", t->shapeDefinitionError);
ASSERT_FALSE(t->shapeDefinitionError) << "isError";
assertEqualsM("synchPointIndex", synchPointIndex, t->getTriggerShapeSynchPointIndex());
@ -1045,7 +1045,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
eth.executeActions();
// injector #1 is low before the test
assertFalseM("injector@0", enginePins.injectors[0].currentLogicValue);
ASSERT_FALSE(enginePins.injectors[0].currentLogicValue) << "injector@0";
eth.firePrimaryTriggerRise();
@ -1069,7 +1069,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
engine->executor.executeAll(timeNowUs + 1);
// injector goes high...
assertFalseM("injector@1", enginePins.injectors[0].currentLogicValue);
ASSERT_FALSE(enginePins.injectors[0].currentLogicValue) << "injector@1";
engine->executor.executeAll(timeNowUs + MS2US(17.5) + 1);
// injector does not go low too soon, that's a feature :)
@ -1089,7 +1089,7 @@ TEST(big, testFuelSchedulerBug299smallAndLarge) {
engine->executor.executeAll(timeNowUs + MS2US(10) + 1);
// end of combined injection
assertFalseM("injector@3", enginePins.injectors[0].currentLogicValue);
ASSERT_FALSE(enginePins.injectors[0].currentLogicValue) << "injector@3";
eth.moveTimeForwardUs(MS2US(20));

View File

@ -49,10 +49,6 @@ void assertTrueM(const char *msg, float actual) {
assertEqualsM(msg, TRUE, actual);
}
void assertFalseM(const char *msg, float actual) {
assertEqualsM(msg, FALSE, actual);
}
void chDbgAssert(int c, char *msg, void *arg) {
if (!c) {
printf("assert failed: %s\r\n", msg);

View File

@ -24,6 +24,5 @@ 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 assertTrueM(const char *msg, float actual);
void assertFalseM(const char *msg, float actual);
#endif /* UNIT_TEST_FRAMEWORK_H_ */