MRPT
2.0.3
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>
12
#include <
mrpt/expr/CRuntimeCompiledExpression.h
>
13
14
template
class
mrpt::CTraitsTest<mrpt::expr::CRuntimeCompiledExpression>;
15
16
TEST
(RuntimeCompiledExpression, SimpleTest)
17
{
18
mrpt::expr::CRuntimeCompiledExpression
expr;
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:74
EXPECT_NEAR
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
CRuntimeCompiledExpression.h
mrpt::expr::CRuntimeCompiledExpression
A wrapper of exprtk runtime expression compiler: it takes a string representing an expression (from a...
Definition:
CRuntimeCompiledExpression.h:61
mrpt::expr::CRuntimeCompiledExpression::eval
double eval() const
Evaluates the current value of the precompiled formula.
Definition:
CRuntimeCompiledExpression.cpp:107
TEST
TEST(RuntimeCompiledExpression, SimpleTest)
Definition:
CRuntimeCompiledExpression_unittest.cpp:16
Page generated by
Doxygen 1.8.17
for MRPT 2.0.3 at Fri May 15 23:51:15 UTC 2020