test_muparser.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
4 #include <boost/bind.hpp>
5 
6 using namespace canopen;
7 
8 double * mapVariable(const std::string &, double *p) {
9  return p;
10 }
11 
12 TEST(TestMuparser, CheckNorm){
13  double input = 0;
14  UnitConverter uc("norm(in,-1000,1000)", boost::bind(HandleLayer::assignVariable, _1, &input, "in"));
15  input = 0; EXPECT_EQ(0, uc.evaluate());
16  input = 10; EXPECT_EQ(10, uc.evaluate());
17  input = -10; EXPECT_EQ(-10, uc.evaluate());
18  input = 1000; EXPECT_EQ(-1000, uc.evaluate());
19  input = 1001; EXPECT_EQ(-999, uc.evaluate());
20  input = 2000; EXPECT_EQ(0, uc.evaluate());
21  input = 2001; EXPECT_EQ(1, uc.evaluate());
22  input = -1000; EXPECT_EQ(-1000, uc.evaluate());
23  input = 999; EXPECT_EQ(999, uc.evaluate());
24 }
25 
26 int main(int argc, char **argv){
27  testing::InitGoogleTest(&argc, argv);
28  return RUN_ALL_TESTS();
29 }
double * mapVariable(const std::string &, double *p)
int main(int argc, char **argv)
static double * assignVariable(const std::string &name, double *ptr, const std::string &req)
Definition: handle_layer.h:129
TEST(TestMuparser, CheckNorm)


canopen_motor_node
Author(s): Mathias Lüdtke
autogenerated on Fri May 14 2021 02:59:45