test_muparser.cpp
Go to the documentation of this file.
00001 #include <gtest/gtest.h>
00002 #include <canopen_motor_node/robot_layer.h>
00003 #include <boost/bind.hpp>
00004 
00005 double * mapVariable(const std::string &, double *p) {
00006     return p;
00007 }
00008 
00009 TEST(TestMuparser, CheckNorm){
00010     double input = 0;
00011     UnitConverter uc("norm(in,-1000,1000)", boost::bind(HandleLayer::assignVariable, _1, &input, "in"));
00012     input = 0; EXPECT_EQ(0, uc.evaluate());
00013     input = 10; EXPECT_EQ(10, uc.evaluate());
00014     input = -10; EXPECT_EQ(-10, uc.evaluate());
00015     input = 1000; EXPECT_EQ(-1000, uc.evaluate());
00016     input = 1001; EXPECT_EQ(-999, uc.evaluate());
00017     input = 2000; EXPECT_EQ(0, uc.evaluate());
00018     input = 2001; EXPECT_EQ(1, uc.evaluate());
00019     input = -1000; EXPECT_EQ(-1000, uc.evaluate());
00020     input = 999; EXPECT_EQ(999, uc.evaluate());
00021 }
00022 
00023 int main(int argc, char **argv){
00024   testing::InitGoogleTest(&argc, argv);
00025   return RUN_ALL_TESTS();
00026 }


canopen_motor_node
Author(s): Mathias Lüdtke
autogenerated on Thu Jun 6 2019 20:44:07