Go to the documentation of this file.00001 #include <iostream>
00002 #include <gtest/gtest.h>
00003 #include <boost/shared_ptr.hpp>
00004 #include <boost/make_shared.hpp>
00005 #include <boost/lexical_cast.hpp>
00006 #include "robot_instance/RobotInstanceFactory.h"
00007 #include "robot_instance/TokenMapLoader.h"
00008 #include <ros/package.h>
00009
00010 using namespace std;
00011
00012 class TokenMapLoaderTest : public ::testing::Test
00013 {
00014 protected:
00015 virtual void SetUp()
00016 {
00017 packagePath = ros::package::getPath("robot_instance");
00018 configPath = packagePath + "/test/config";
00019 configSafetyPath = packagePath + "/test/configSafety";
00020 fileName = "TestRobotInstance.xml";
00021 instance = RobotInstanceFactory::createRobotInstanceFromFile(configPath, configSafetyPath, fileName);
00022
00023 tokenMap = boost::make_shared<TokenMap>();
00024 }
00025
00026 virtual void TearDown()
00027 {
00028 }
00029
00030 string packagePath, configPath, configSafetyPath, fileName;
00031 RobotInstancePtr instance;
00032 TokenMapPtr tokenMap;
00033 };
00034
00035 TEST_F(TokenMapLoaderTest, LoadElements)
00036 {
00037 string s;
00038
00039 TokenMapLoader::loadElements(instance, tokenMap);
00040
00041
00042 std::vector<std::string> names;
00043
00044 for (TokenMap::iterator it = tokenMap->begin(); it != tokenMap->end(); ++it)
00045 {
00046 names.push_back(it->first);
00047 }
00048
00049 EXPECT_EQ(7782, names.size());
00050 sort(names.begin(), names.end());
00051
00052 EXPECT_STREQ("/body/pdmc/0x00", names[0].c_str());
00053 EXPECT_EQ(0x00, tokenMap->operator[](names[0]));
00054
00055 EXPECT_STREQ("/body/pdmc/0x01", names[1].c_str());
00056 EXPECT_EQ(0x01, tokenMap->operator[](names[1]));
00057
00058
00059
00060 EXPECT_STREQ("right_arm", names[7780].c_str());
00061 EXPECT_EQ(0x00, tokenMap->operator[](names[7780]));
00062
00063 EXPECT_STREQ("right_leg", names[7781].c_str());
00064 EXPECT_EQ(0x01, tokenMap->operator[](names[7781]));
00065 }
00066
00067 int main(int argc, char** argv)
00068 {
00069 testing::InitGoogleTest(&argc, argv);
00070 return RUN_ALL_TESTS();
00071 }