MRPT  2.0.4
CRuntimeCompiledExpression_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <CTraitsTest.h>
11 #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 
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.
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020