migrating to googletest
This commit is contained in:
parent
73aa22573e
commit
cc300145b3
|
@ -11,7 +11,7 @@
|
|||
#include "unit_test_framework.h"
|
||||
|
||||
static void testIndex(const int expected, const float array[], int size, float value) {
|
||||
assertEquals(expected, findIndex(array, size, value));
|
||||
ASSERT_EQ(expected, findIndex(array, size, value));
|
||||
assertEquals(expected, findIndex2(array, size, value));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,30 +45,30 @@ float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
static void testParsing(void) {
|
||||
char buffer[64];
|
||||
|
||||
assertTrue(strEqualCaseInsensitive("hello", "HELlo"));
|
||||
assertFalse(strEqualCaseInsensitive("hello", "HElo2"));
|
||||
ASSERT_TRUE(strEqualCaseInsensitive("hello", "HELlo"));
|
||||
ASSERT_FALSE(strEqualCaseInsensitive("hello", "HElo2"));
|
||||
|
||||
const char *ptr;
|
||||
ptr = getNextToken(" hello ", buffer, sizeof(buffer));
|
||||
assertTrue(strEqual("hello", buffer));
|
||||
ASSERT_TRUE(strEqual("hello", buffer));
|
||||
|
||||
ptr = getNextToken("hello", buffer, sizeof(buffer));
|
||||
assertTrue(strEqual("hello", buffer));
|
||||
ASSERT_TRUE(strEqual("hello", buffer));
|
||||
|
||||
ptr = getNextToken(" hello world ", buffer, sizeof(buffer));
|
||||
assertTrue(strEqual("hello", buffer));
|
||||
ASSERT_TRUE(strEqual("hello", buffer));
|
||||
ptr = getNextToken(ptr, buffer, sizeof(buffer));
|
||||
assertTrue(strEqual("world", buffer));
|
||||
ASSERT_TRUE(strEqual("world", buffer));
|
||||
|
||||
assertTrue(isNumeric("123"));
|
||||
assertFalse(isNumeric("a123"));
|
||||
ASSERT_TRUE(isNumeric("123"));
|
||||
ASSERT_FALSE(isNumeric("a123"));
|
||||
|
||||
LEElement thepool[TEST_POOL_SIZE];
|
||||
LEElementPool pool(thepool, TEST_POOL_SIZE);
|
||||
|
||||
LEElement *element;
|
||||
element = pool.parseExpression("1 3 AND not");
|
||||
assertTrue(element != NULL);
|
||||
ASSERT_TRUE(element != NULL);
|
||||
|
||||
assertEquals(element->action, LE_NUMERIC_VALUE);
|
||||
assertEquals(element->fValue, 1.0);
|
||||
|
@ -84,7 +84,7 @@ static void testParsing(void) {
|
|||
assertEquals(element->action, LE_OPERATOR_NOT);
|
||||
|
||||
element = element->next;
|
||||
assertTrue(element == NULL);
|
||||
ASSERT_TRUE(element == NULL);
|
||||
}
|
||||
|
||||
static void testExpression2(float selfValue, const char *line, float expected) {
|
||||
|
|
|
@ -83,13 +83,13 @@ static void testDodgeNeonDecoder(void) {
|
|||
// assertFalseM("4 shaft_is_synchronized", state.shaft_is_synchronized); // still no synchronization
|
||||
//
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630);
|
||||
// assertFalse(state.shaft_is_synchronized); // still no synchronization
|
||||
// ASSERT_FALSE(state.shaft_is_synchronized); // still no synchronization
|
||||
//
|
||||
// printf("2nd camshaft revolution\r\n");
|
||||
// r = 720;
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210);
|
||||
// assertTrue(state.shaft_is_synchronized);
|
||||
// ASSERT_TRUE(state.shaft_is_synchronized);
|
||||
// assertEquals(0, state.current_index);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420);
|
||||
// assertEquals(1, state.current_index);
|
||||
|
@ -101,7 +101,7 @@ static void testDodgeNeonDecoder(void) {
|
|||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60);
|
||||
// assertEqualsM("current index", 3, state.current_index);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210);
|
||||
// assertTrue(state.shaft_is_synchronized);
|
||||
// ASSERT_TRUE(state.shaft_is_synchronized);
|
||||
// assertEqualsM("current index", 0, state.current_index);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630);
|
||||
|
@ -127,7 +127,7 @@ TEST(misc, testSomethingWeird) {
|
|||
sta->decodeTriggerEvent(SHAFT_PRIMARY_FALLING, r PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
assertFalseM("shaft_is_synchronized", sta->shaft_is_synchronized); // still no synchronization
|
||||
sta->decodeTriggerEvent(SHAFT_PRIMARY_RISING, ++r PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
assertTrue(sta->shaft_is_synchronized); // first signal rise synchronize
|
||||
ASSERT_TRUE(sta->shaft_is_synchronized); // first signal rise synchronize
|
||||
assertEquals(0, sta->getCurrentIndex());
|
||||
sta->decodeTriggerEvent(SHAFT_PRIMARY_FALLING, r++ PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
assertEquals(1, sta->getCurrentIndex());
|
||||
|
|
|
@ -324,7 +324,7 @@ TEST(misc, testConsoleLogic) {
|
|||
assertEquals(5, findEndOfToken(cmd));
|
||||
|
||||
strcpy(buffer, "echo");
|
||||
assertTrue(strEqual("echo", unquote(buffer)));
|
||||
ASSERT_TRUE(strEqual("echo", unquote(buffer)));
|
||||
|
||||
strcpy(buffer, "\"echo\"");
|
||||
assertTrueM("unquote quoted", strEqual("echo", unquote(buffer)));
|
||||
|
@ -371,7 +371,7 @@ TEST(misc, testConsoleLogic) {
|
|||
|
||||
strcpy(buffer, "echosss \" 1\" 222 333");
|
||||
handleConsoleLine(buffer);
|
||||
assertTrue(strEqual("\" 1\"", lastFirst));
|
||||
ASSERT_TRUE(strEqual("\" 1\"", lastFirst));
|
||||
|
||||
//addConsoleActionSSS("GPS", testGpsParser);
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ TEST(misc, testMisc) {
|
|||
print("******************************************* testMisc\r\n");
|
||||
strcpy(buff, " ab ");
|
||||
// we need a mutable array here
|
||||
assertTrue(strEqual("ab", efiTrim(buff)));
|
||||
ASSERT_TRUE(strEqual("ab", efiTrim(buff)));
|
||||
|
||||
|
||||
{
|
||||
|
@ -458,25 +458,25 @@ TEST(misc, testMenuTree) {
|
|||
tree.init(&miTopLevel1, 3);
|
||||
|
||||
tree.nextItem();
|
||||
assertTrue(tree.topVisible == &miTopLevel1);
|
||||
assertTrue(tree.current == &miTopLevel2);
|
||||
ASSERT_TRUE(tree.topVisible == &miTopLevel1);
|
||||
ASSERT_TRUE(tree.current == &miTopLevel2);
|
||||
|
||||
tree.back();
|
||||
assertTrue(tree.current == &miTopLevel2); // no 'back' since we are on the top level already
|
||||
ASSERT_TRUE(tree.current == &miTopLevel2); // no 'back' since we are on the top level already
|
||||
|
||||
tree.nextItem();
|
||||
assertTrue(tree.topVisible == &miTopLevel1);
|
||||
assertTrue(tree.current == &miTopLevel3);
|
||||
ASSERT_TRUE(tree.topVisible == &miTopLevel1);
|
||||
ASSERT_TRUE(tree.current == &miTopLevel3);
|
||||
|
||||
tree.nextItem();
|
||||
assertTrue(tree.topVisible == &miTopLevel2);
|
||||
assertTrue(tree.current == &miTopLevel4);
|
||||
ASSERT_TRUE(tree.topVisible == &miTopLevel2);
|
||||
ASSERT_TRUE(tree.current == &miTopLevel4);
|
||||
|
||||
tree.enterSubMenu();
|
||||
assertTrueM("still same", tree.current == &miTopLevel4); // no children in this one
|
||||
|
||||
tree.nextItem();
|
||||
assertTrue(tree.topVisible == &miTopLevel3);
|
||||
ASSERT_TRUE(tree.topVisible == &miTopLevel3);
|
||||
assertTrueM("tl5", tree.current == &miTopLevel5);
|
||||
|
||||
tree.nextItem();
|
||||
|
@ -489,10 +489,10 @@ TEST(misc, testMenuTree) {
|
|||
tree.nextItem();
|
||||
|
||||
tree.enterSubMenu();
|
||||
assertTrue(tree.current == &miSubMenu5_1);
|
||||
ASSERT_TRUE(tree.current == &miSubMenu5_1);
|
||||
|
||||
tree.back();
|
||||
assertTrue(tree.current == &miTopLevel1);
|
||||
ASSERT_TRUE(tree.current == &miTopLevel1);
|
||||
}
|
||||
|
||||
int getRusEfiVersion(void) {
|
||||
|
|
|
@ -53,18 +53,10 @@ void assertTrueM(const char *msg, float actual) {
|
|||
assertEqualsM(msg, TRUE, actual);
|
||||
}
|
||||
|
||||
void assertTrue(float actual) {
|
||||
assertTrueM("", actual);
|
||||
}
|
||||
|
||||
void assertFalseM(const char *msg, float actual) {
|
||||
assertEqualsM(msg, FALSE, actual);
|
||||
}
|
||||
|
||||
void assertFalse(float actual) {
|
||||
assertFalseM("", actual);
|
||||
}
|
||||
|
||||
void chDbgAssert(int c, char *msg, void *arg) {
|
||||
if (!c) {
|
||||
printf("assert failed: %s\r\n", msg);
|
||||
|
|
Loading…
Reference in New Issue