Main MRPT website > C++ reference for 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 }
mrpt::expr::CRuntimeCompiledExpression::compile
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.
Definition: CRuntimeCompiledExpression.cpp:47
CRuntimeCompiledExpression.h
mrpt::expr::CRuntimeCompiledExpression
A wrapper of exprtk runtime expression compiler: it takes a string representing an expression (from a...
Definition: CRuntimeCompiledExpression.h:52
mrpt::expr::CRuntimeCompiledExpression::eval
double eval() const
Evaluates the current value of the precompiled formula.
Definition: CRuntimeCompiledExpression.cpp:82
TEST
TEST(RuntimeCompiledExpression, SimpleTest)
Definition: CRuntimeCompiledExpression_unittest.cpp:16



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST