ExprParser::ExprParser(const char *expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false),_expr(expr)
{
+ _expr=deleteWhiteSpaces(_expr);
}
//! For \b NOT null terminated strings coming from FORTRAN.
ExprParser::ExprParser(const char *expr, int lgth, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false)
{
_expr=buildStringFromFortran(expr,lgth);
+ _expr=deleteWhiteSpaces(_expr);
}
ExprParser::~ExprParser()
expr3.evaluateExpr(1,input,res2);
CPPUNIT_ASSERT_DOUBLES_EQUAL(9.8,res2[0],1e-12);
}
+
+/*!
+ * Bug detected by Marc concerning expressions with blanks.
+ */
+void ExprEvalInterpTest::testInterpreter4()
+{
+ INTERP_KERNEL::ExprParser expr("2*x + 1");
+ double vals[3]={0.1,0.2,0.3};
+ std::vector<std::string> varsV(3);
+ varsV[0] = "x";
+ varsV[1] = "y";
+ varsV[2] = "z";
+ expr.parse();
+ expr.prepareExprEvaluation(varsV);
+ double result;
+ expr.evaluateExpr(1,vals, &result);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2,result,1e-12);
+}
CPPUNIT_TEST( testInterpreterUnit0 );
CPPUNIT_TEST( testInterpreterUnit1 );
CPPUNIT_TEST( testInterpreter3 );
+ CPPUNIT_TEST( testInterpreter4 );
CPPUNIT_TEST_SUITE_END();
public:
void setUp() { }
void testInterpreter1();
void testInterpreter2();
void testInterpreter3();
+ void testInterpreter4();
void testInterpreterUnit0();
void testInterpreterUnit1();
};