$search
00001 00002 /* 00003 * Copyright (C) 2008, Morgan Quigley and Willow Garage, Inc. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * * Redistributions of source code must retain the above copyright notice, 00008 * this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its 00013 * contributors may be used to endorse or promote products derived from 00014 * this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00019 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00020 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00021 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00022 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00023 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00024 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00025 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00026 * POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00033 /* 00034 * Test compilation of all the different service callback types 00035 */ 00036 00037 #include <gtest/gtest.h> 00038 #include "ros/ros.h" 00039 #include "test_roscpp/TestStringString.h" 00040 00041 #include <vector> 00042 00043 bool add(test_roscpp::TestStringString::Request &req, 00044 test_roscpp::TestStringString::Response &res ) 00045 { 00046 return true; 00047 } 00048 00049 bool add2(ros::ServiceEvent<test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response>& event) 00050 { 00051 return true; 00052 } 00053 00054 bool add3(ros::ServiceEvent<test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response>& event, const std::string& bound) 00055 { 00056 return true; 00057 } 00058 00059 struct A 00060 { 00061 bool add(test_roscpp::TestStringString::Request &req, 00062 test_roscpp::TestStringString::Response &res ) 00063 { 00064 return true; 00065 } 00066 00067 bool add2(ros::ServiceEvent<test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response>& event) 00068 { 00069 return true; 00070 } 00071 00072 bool add3(ros::ServiceEvent<test_roscpp::TestStringString::Request, test_roscpp::TestStringString::Response>& event, const std::string& bound) 00073 { 00074 return true; 00075 } 00076 }; 00077 00078 TEST(ServiceCallbackTypes, compile) 00079 { 00080 ros::NodeHandle n; 00081 00082 std::vector<ros::ServiceServer> srvs; 00083 srvs.push_back(n.advertiseService("add_two_ints", add)); 00084 srvs.push_back(n.advertiseService("add_two_ints2", add2)); 00085 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")))); 00086 00087 A a; 00088 srvs.push_back(n.advertiseService("add_two_ints10", &A::add, &a)); 00089 srvs.push_back(n.advertiseService("add_two_ints11", &A::add2, &a)); 00090 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")))); 00091 } 00092 00093 int main(int argc, char **argv) 00094 { 00095 testing::InitGoogleTest(&argc, argv); 00096 00097 ros::init( argc, argv, "subscription_callback_types" ); 00098 ros::NodeHandle nh; 00099 00100 return RUN_ALL_TESTS(); 00101 }