39 #include <gtest/gtest.h> 40 #include <std_msgs/Bool.h> 41 #include <std_msgs/Byte.h> 42 #include <std_msgs/Empty.h> 43 #include <std_msgs/String.h> 44 #include <std_msgs/Float32.h> 47 TEST(SameNamespaces, NodeletPrivateNodehandle) {
52 bool found_topic =
false;
54 for (ros::master::V_TopicInfo::iterator it = master_topics.begin() ; it != master_topics.end(); it++) {
56 if (info.
datatype.compare(
"std_msgs/Bool") == 0) {
58 EXPECT_STREQ(
"/common_namespace/nodehandle_test/private", info.
name.c_str());
61 EXPECT_TRUE(found_topic);
64 TEST(SameNamespaces, NodeletNamespacedNodehandle) {
69 bool found_topic =
false;
71 for (ros::master::V_TopicInfo::iterator it = master_topics.begin() ; it != master_topics.end(); it++) {
73 if (info.
datatype.compare(
"std_msgs/Byte") == 0) {
75 EXPECT_STREQ(
"/common_namespace/namespaced", info.
name.c_str());
78 EXPECT_TRUE(found_topic);
81 TEST(SameNamespaces, NodeletGlobalNodehandle) {
86 bool found_topic =
false;
88 for (ros::master::V_TopicInfo::iterator it = master_topics.begin() ; it != master_topics.end(); it++) {
90 if (info.
datatype.compare(
"std_msgs/Time") == 0) {
92 EXPECT_STREQ(
"/global", info.
name.c_str());
95 EXPECT_TRUE(found_topic);
98 TEST(SameNamespaces, NodePrivateNodehandle) {
103 bool found_topic =
false;
105 for (ros::master::V_TopicInfo::iterator it = master_topics.begin() ; it != master_topics.end(); it++) {
107 if (info.
datatype.compare(
"std_msgs/Empty") == 0) {
109 EXPECT_STREQ(
"/common_namespace/test_nodehandles/private", info.
name.c_str());
112 EXPECT_TRUE(found_topic);
115 TEST(SameNamespaces, NodeNamespacedNodehandle) {
120 bool found_topic =
false;
122 for (ros::master::V_TopicInfo::iterator it = master_topics.begin() ; it != master_topics.end(); it++) {
124 if (info.
datatype.compare(
"std_msgs/String") == 0) {
126 EXPECT_STREQ(
"/common_namespace/namespaced", info.
name.c_str());
129 EXPECT_TRUE(found_topic);
132 TEST(SameNamespaces, NodeGlobalNodehandle) {
137 bool found_topic =
false;
139 for (ros::master::V_TopicInfo::iterator it = master_topics.begin() ; it != master_topics.end(); it++) {
141 if (info.
datatype.compare(
"std_msgs/Float32") == 0) {
143 EXPECT_STREQ(
"/public", info.
name.c_str());
146 EXPECT_TRUE(found_topic);
149 int main(
int argc,
char **argv) {
150 testing::InitGoogleTest(&argc, argv);
151 ros::init(argc, argv,
"test_nodehandles_same_namespaces");
152 return RUN_ALL_TESTS();
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL bool getTopics(V_TopicInfo &topics)
int main(int argc, char **argv)
std::vector< TopicInfo > V_TopicInfo
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
TEST(SameNamespaces, NodeletPrivateNodehandle)