11#include " BenchMTParser.h"
22
33#include < cmath>
4- #include < Oleauto.h>
54// MTParser
65#include " MTParser/MTParserLib/MTParser.h"
76#include " MTParser/MTParserLib/MTParserExcepStrEng.h"
@@ -76,6 +75,51 @@ double BenchMTParser::DoBenchmark(const std::string& sExpr, long iCount)
7675
7776 p.defineFunc (new ExpFct ());
7877
78+ // Perform basic tests for the variables used
79+ // in the expressions
80+ {
81+ bool test_result = true ;
82+
83+ auto tests_list = test_expressions ();
84+
85+ for (auto test : tests_list)
86+ {
87+ MTParser test_p;
88+ test_p.defineVar (" a" , &a);
89+ test_p.defineVar (" b" , &b);
90+ test_p.defineVar (" c" , &c);
91+
92+ test_p.defineVar (" x" , &x);
93+ test_p.defineVar (" y" , &y);
94+ test_p.defineVar (" z" , &z);
95+ test_p.defineVar (" w" , &w);
96+
97+ test_p.defineFunc (new ExpFct ());
98+
99+ try
100+ {
101+ test_p.compile (test.first .c_str ());
102+
103+ if (!is_equal (test.second ,test_p.evaluate ()))
104+ {
105+ test_result = false ;
106+ break ;
107+ }
108+ }
109+ catch (MTParserException&)
110+ {
111+ test_result = false ;
112+ break ;
113+ }
114+ }
115+
116+ if (!test_result)
117+ {
118+ StopTimerAndReport (" Failed variable test" );
119+ return m_fTime1;
120+ }
121+ }
122+
79123 double fTime = 0 ;
80124 double fRes = 0 ;
81125 double fSum = 0 ;
@@ -84,7 +128,7 @@ double BenchMTParser::DoBenchmark(const std::string& sExpr, long iCount)
84128 {
85129 p.compile (sExpr .c_str ());
86130 }
87- catch (MTParserException & e)
131+ catch (MTParserException& e)
88132 {
89133 StopTimerAndReport (e.getDesc (0 ).c_str ());
90134 return std::numeric_limits<double >::quiet_NaN ();
0 commit comments