Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <string>
00037
00038 #include <gtest/gtest.h>
00039
00040 #include <ros/ros.h>
00041 #include <ros/names.h>
00042 #include <test_roscpp/TestArray.h>
00043 #include <test_roscpp/TestStringInt.h>
00044 #include <test_roscpp/TestEmpty.h>
00045
00046 const char* g_node_name = "inspection_test";
00047
00048 int g_argc;
00049 char* g_argv[8];
00050
00051 TEST(Inspection, getAdvertisedTopics)
00052 {
00053 ros::NodeHandle nh;
00054
00055 std::vector<std::string> topics;
00056
00057 ros::this_node::getAdvertisedTopics(topics);
00058
00059
00060 ASSERT_EQ((int)topics.size(),1);
00061 ASSERT_EQ(topics[0], "/rosout");
00062
00063 {
00064 ros::Publisher pub1 = nh.advertise<test_roscpp::TestArray>("topic",1);
00065 ros::Publisher pub2 = nh.advertise<test_roscpp::TestArray>("ns/topic",1);
00066 ros::Publisher pub3 = nh.advertise<test_roscpp::TestArray>("/global/topic",1);
00067
00068 topics.clear();
00069 ros::this_node::getAdvertisedTopics(topics);
00070
00071
00072 ASSERT_EQ((int)topics.size(),4);
00073
00074
00075
00076 ASSERT_EQ(topics[0], "/rosout");
00077 ASSERT_EQ(topics[1], "/topic");
00078 ASSERT_EQ(topics[2], "/ns/topic");
00079 ASSERT_EQ(topics[3], "/global/topic");
00080 }
00081
00082 topics.clear();
00083 ros::this_node::getAdvertisedTopics(topics);
00084
00085
00086 ASSERT_EQ((int)topics.size(),1);
00087 ASSERT_EQ(topics[0], "/rosout");
00088 }
00089
00090 TEST(Inspection, commandLineParsing)
00091 {
00092 ASSERT_EQ(g_argc, 5);
00093 ros::M_string remappings = ros::names::getRemappings();
00094
00095 ASSERT_STREQ(remappings["/foo"].c_str(), "/bar");
00096 ASSERT_STREQ(remappings["/baz"].c_str(), "/bang");
00097 ASSERT_STREQ(remappings["/bomb"].c_str(), "/barn");
00098 }
00099
00100 int
00101 main(int argc, char** argv)
00102 {
00103 testing::InitGoogleTest(&argc, argv);
00104
00105 g_argc = 8;
00106
00107 g_argv[0] = strdup(argv[0]);
00108 g_argv[1] = strdup("foo:=bar");
00109 g_argv[2] = strdup("bat");
00110 g_argv[3] = strdup("baz:=bang");
00111 g_argv[4] = strdup("boom");
00112 g_argv[5] = strdup("baz=bomb");
00113 g_argv[6] = strdup("bomb:=barn");
00114 g_argv[7] = strdup("--bangbang");
00115
00116 ros::init( g_argc, g_argv, "inspection" );
00117 ros::NodeHandle nh;
00118
00119 return RUN_ALL_TESTS();
00120 }