]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug correction when some blank in expr.
authorageay <ageay>
Thu, 10 Feb 2011 15:22:15 +0000 (15:22 +0000)
committerageay <ageay>
Thu, 10 Feb 2011 15:22:15 +0000 (15:22 +0000)
src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx
src/INTERP_KERNELTest/ExprEvalInterpTest.cxx
src/INTERP_KERNELTest/ExprEvalInterpTest.hxx

index 2d8055ffe310600c5958e2aeb1402c1fdeeab415..2aa5ead3b1078ebad55825919de9d158b0ff052a 100644 (file)
@@ -124,12 +124,14 @@ LeafExprVar::~LeafExprVar()
 
 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()
index 96032f6a3433942ad1361a49ccedf3f6b9364a11..2bce00618ddd78940d6ba45bd22b6028fd62e4a7 100644 (file)
@@ -437,3 +437,21 @@ void ExprEvalInterpTest::testInterpreter3()
   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);
+}
index 2730af59a0a3ab544581926344e32cd8e72e7f09..b43050cb1e51014b8bccfc05a16f3c9b805dcb96 100644 (file)
@@ -37,6 +37,7 @@ namespace INTERP_TEST
     CPPUNIT_TEST( testInterpreterUnit0 );
     CPPUNIT_TEST( testInterpreterUnit1 );
     CPPUNIT_TEST( testInterpreter3 );
+    CPPUNIT_TEST( testInterpreter4 );
     CPPUNIT_TEST_SUITE_END();
   public:
     void setUp() { }
@@ -48,6 +49,7 @@ namespace INTERP_TEST
     void testInterpreter1();
     void testInterpreter2();
     void testInterpreter3();
+    void testInterpreter4();
     void testInterpreterUnit0();
     void testInterpreterUnit1();
   };