service_callback_types.cpp
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 2008, Morgan Quigley and Willow Garage, Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
33 /*
34  * Test compilation of all the different service callback types
35  */
36 
37 #include <gtest/gtest.h>
38 #include "ros/ros.h"
39 #include "test_roscpp/TestStringString.h"
40 
41 #include <vector>
42 
43 bool add(test_roscpp::TestStringString::Request &,
44  test_roscpp::TestStringString::Response &)
45 {
46  return true;
47 }
48 
50 {
51  return true;
52 }
53 
55 {
56  return true;
57 }
58 
59 struct A
60 {
61  bool add(test_roscpp::TestStringString::Request &,
62  test_roscpp::TestStringString::Response &)
63  {
64  return true;
65  }
66 
68  {
69  return true;
70  }
71 
73  {
74  return true;
75  }
76 };
77 
78 TEST(ServiceCallbackTypes, compile)
79 {
81 
82  std::vector<ros::ServiceServer> srvs;
83  srvs.push_back(n.advertiseService("add_two_ints", add));
84  srvs.push_back(n.advertiseService("add_two_ints2", add2));
85  srvs.push_back(n.advertiseService<ros::ServiceEvent<test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response> >("add_two_ints3", boost::bind(add3, _1, std::string("blah"))));
86 
87  A a;
88  srvs.push_back(n.advertiseService("add_two_ints10", &A::add, &a));
89  srvs.push_back(n.advertiseService("add_two_ints11", &A::add2, &a));
90  srvs.push_back(n.advertiseService<ros::ServiceEvent<test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response> >("add_two_ints12", boost::bind(&A::add3, &a, _1, std::string("blah"))));
91 }
92 
93 int main(int argc, char **argv)
94 {
95  testing::InitGoogleTest(&argc, argv);
96 
97  ros::init( argc, argv, "subscription_callback_types" );
98  ros::NodeHandle nh;
99 
100  return RUN_ALL_TESTS();
101 }
bool add2(ros::ServiceEvent< test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response > &)
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
TEST(ServiceCallbackTypes, compile)
bool add(test_roscpp::TestStringString::Request &, test_roscpp::TestStringString::Response &)
bool add3(ros::ServiceEvent< test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response > &, const std::string &)
bool add(test_roscpp::TestStringString::Request &, test_roscpp::TestStringString::Response &)
bool add3(ros::ServiceEvent< test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response > &, const std::string &)
bool add2(ros::ServiceEvent< test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response > &)


test_roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
autogenerated on Mon Nov 2 2020 03:52:46