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