MRPT  1.9.9
CRuntimeCompiledExpression_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
11 #include <CTraitsTest.h>
12 #include <gtest/gtest.h>
13 
14 template class mrpt::CTraitsTest<mrpt::expr::CRuntimeCompiledExpression>;
15 
16 TEST(RuntimeCompiledExpression, SimpleTest)
17 {
19  std::map<std::string, double> vars;
20 
21  vars["x"] = 5.0;
22  vars["y"] = 3.0;
23  expr.compile("x^2+x*y+1", vars);
24 
25  EXPECT_NEAR(
26  expr.eval(), vars["x"] * vars["x"] + vars["x"] * vars["y"] + 1.0, 1e-9);
27 }
A wrapper of exprtk runtime expression compiler: it takes a string representing an expression (from a...
TEST(RuntimeCompiledExpression, SimpleTest)
void compile(const std::string &expression, const std::map< std::string, double > &variables=std::map< std::string, double >(), const std::string &expr_name_for_error_reporting=std::string())
Initializes the object by compiling an expression.
double eval() const
Evaluates the current value of the precompiled formula.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020