{
std::size_t pos=_expr.find_first_not_of("+-",0,2);
std::string minimizedExpr=_expr.substr(pos);
- std::size_t pos2=minimizedExpr.find_first_of("+-*/^()",0,7);
+ std::size_t pos2=minimizedExpr.find_first_of("+-*/^()<>",0,9);
if(pos2!=std::string::npos)
return false;
delete _leaf;
void ExprEvalInterpTest::testInterpreter3()
{
+ std::set<std::string> res;
+ double input[3];
+ double res2[3];
INTERP_KERNEL::ExprParser expr1("2.3+x>5.");
expr1.parse();
- std::set<std::string> res;
expr1.getSetOfVars(res);
CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
CPPUNIT_ASSERT(*(res.begin())=="x");
expr1.prepareExprEvaluationVec();
- double input[3];
input[0]=0.;
- double res2[3];
expr1.evaluateExpr(1,input,res2);
CPPUNIT_ASSERT(-std::numeric_limits<double>::max()==res2[0]);
input[0]=2.8;
input[0]=2.6;
expr3.evaluateExpr(1,input,res2);
CPPUNIT_ASSERT_DOUBLES_EQUAL(9.8,res2[0],1e-12);
+ //
+ INTERP_KERNEL::ExprParser expr4("if(x>1000,2*x,x/3)");
+ expr4.parse();
+ res.clear();
+ expr4.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ expr4.prepareExprEvaluationVec();
+ input[0]=2.7;
+ expr4.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.9,res2[0],1e-12);
+ input[0]=999.;
+ expr4.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(333.,res2[0],1e-12);
+ input[0]=1002.;
+ expr4.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2004.,res2[0],1e-12);
}
/*!