fome-fw/unit_tests/test_logic_expression.cpp

70 lines
1.3 KiB
C++
Raw Normal View History

2014-10-03 09:03:02 -07:00
/**
* @file test_logic_expression.cpp
*
* https://sourceforge.net/p/rusefi/tickets/102/
*
* @date Oct 3, 2014
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#include "main.h"
#include "test_logic_expression.h"
2014-10-03 12:05:03 -07:00
#include "logic_expression.h"
2014-10-03 09:03:02 -07:00
void testLogicExpressions(void) {
2014-10-03 12:05:03 -07:00
printf("*************************************************** testLogicExpressions\r\n");
LECalculator c;
LEElement value1;
value1.init(LE_NUMERIC_VALUE, 123.0);
c.add(&value1);
assertEqualsM("123", 123.0, c.getValue());
LEElement value2;
value2.init(LE_NUMERIC_VALUE, 321.0);
c.add(&value2);
LEElement value3;
value3.init(LE_OPERATOR_AND);
c.add(&value3);
2014-10-03 14:03:00 -07:00
assertEqualsM("123 and 321", 1.0, c.getValue());
2014-10-03 12:05:03 -07:00
2014-10-03 09:03:02 -07:00
/**
* fuel_pump = (time_since_boot < 4 seconds) OR (rpm > 0)
* fuel_pump = time_since_boot 4 less rpm 0 more OR
*/
2014-10-03 15:03:01 -07:00
c.reset();
LEElementPool pool;
LEElement *e = pool.next();
e->init(LE_METHOD_TIME_SINCE_BOOT);
e = pool.next();
e->init(LE_NUMERIC_VALUE, 4);
e = pool.next();
e->init(LE_OPERATOR_LESS);
e = pool.next();
e->init(LE_METHOD_RPM);
e = pool.next();
e->init(LE_NUMERIC_VALUE, 0);
e = pool.next();
e->init(LE_OPERATOR_MORE);
e = pool.next();
e->init(LE_OPERATOR_OR);
2014-10-03 09:03:02 -07:00
/**
* fan = (not fan && coolant > 90) OR (fan && coolant > 85)
* fan = fan NOT coolant 90 AND more fan coolant 85 more AND OR
*/
}