subscribers.cpp
Go to the documentation of this file.
00001 #include <gtest/gtest.h>
00002 
00003 #include <std_msgs/Int32.h>
00004 #include <ros/duration.h>
00005 #include <ros/publisher.h>
00006 #include <ros/node_handle.h>
00007 
00008 #include <atomic>
00009 #include <iostream>
00010 
00011 TEST(Subscriber, internal)
00012 {
00013   ros::NodeHandle node_handle;
00014   int queue_size = 1;
00015   ros::Publisher publisher_to_interal_topic = node_handle.advertise<std_msgs::Int32>("fibonacci_publisher_internal",
00016                                                                                      queue_size);
00017 
00018   while (publisher_to_interal_topic.getNumSubscribers() == 0 && ros::ok())
00019   {
00020     ros::Duration(0.001).sleep();
00021   }
00022 
00023   EXPECT_EQ(publisher_to_interal_topic.getNumSubscribers(), 1);
00024 }
00025 
00026 int main(int argc, char **argv)
00027 {
00028   testing::InitGoogleTest(&argc, argv);
00029   int time_seed = static_cast<int>(time(0));
00030   srand(time_seed);
00031 
00032   ros::init(argc, argv, "subscribers");
00033 
00034   return RUN_ALL_TESTS();
00035 }


ros1_ros_cpptemplate
Author(s): Alexander Reimann
autogenerated on Fri Sep 1 2017 02:23:42