38 #include <gtest/gtest.h> 45 #include <test_roscpp/TestStringString.h> 46 #include <test_roscpp/BadTestStringString.h> 50 test_roscpp::TestStringString::Request req;
51 test_roscpp::TestStringString::Response res;
53 req.str = std::string(
"case_FLIP");
58 ASSERT_STREQ(res.str.c_str(),
"CASE_flip");
61 TEST(SrvCall, callSrvUnicode)
63 test_roscpp::TestStringString::Request req;
64 test_roscpp::TestStringString::Response res;
66 req.str = std::string(
"ロボット");
71 ASSERT_STREQ(res.str.c_str(),
"ロボット");
74 TEST(SrvCall, callSrvMultipleTimes)
76 test_roscpp::TestStringString::Request req;
77 test_roscpp::TestStringString::Response res;
79 req.str = std::string(
"case_FLIP");
85 for (
int i = 0; i < 100; ++i)
92 printf(
"100 calls took %f secs\n", d.
toSec());
94 ASSERT_STREQ(res.str.c_str(),
"CASE_flip");
97 TEST(SrvCall, callSrvWithWrongType)
99 test_roscpp::BadTestStringString::Request req;
100 test_roscpp::BadTestStringString::Response res;
104 for (
int i = 0; i < 4; ++i )
107 ASSERT_FALSE(call_result);
113 test_roscpp::TestStringString::Request req;
114 test_roscpp::TestStringString::Response res;
116 req.str = std::string(
"case_FLIP");
118 std::map<std::string, std::string>
header;
119 header[
"test1"] =
"testing 1";
120 header[
"test2"] =
"testing 2";
127 for (
int i = 0; i < 100; ++i)
129 ASSERT_TRUE(handle.
call(req, res));
134 printf(
"100 calls took %f secs\n", d.
toSec());
136 ASSERT_STREQ(res.str.c_str(),
"CASE_flip");
139 TEST(SrvCall, callSrvPersistentHandle)
141 test_roscpp::TestStringString::Request req;
142 test_roscpp::TestStringString::Response res;
144 req.str = std::string(
"case_FLIP");
148 std::map<std::string, std::string>
header;
149 header[
"test1"] =
"testing 1";
150 header[
"test2"] =
"testing 2";
156 for (
int i = 0; i < 10000; ++i)
158 ASSERT_TRUE(handle.
call(req, res));
163 printf(
"10000 calls took %f secs\n", d.
toSec());
165 ASSERT_STREQ(res.str.c_str(),
"CASE_flip");
168 TEST(SrvCall, callSrvLongRunning)
170 test_roscpp::TestStringString::Request req;
171 test_roscpp::TestStringString::Response res;
173 req.str = std::string(
"case_FLIP");
178 ASSERT_STREQ(res.str.c_str(),
"CASE_flip");
181 TEST(SrvCall, callSrvWhichUnadvertisesInCallback)
183 test_roscpp::TestStringString::Request req;
184 test_roscpp::TestStringString::Response res;
186 req.str = std::string(
"case_FLIP");
194 test_roscpp::TestStringString::Request req;
195 test_roscpp::TestStringString::Response res;
197 req.str = std::string(
"case_FLIP");
201 std::map<std::string, std::string>
header;
202 header[
"test1"] =
"testing 1";
203 header[
"test2"] =
"testing 2";
206 ASSERT_TRUE(handle.
call(req, res));
209 ASSERT_FALSE(handle.
isValid());
211 ASSERT_STREQ(res.str.c_str(),
"CASE_flip");
214 TEST(SrvCall, waitForServiceTimeout)
227 testing::InitGoogleTest(&argc, argv);
232 int ret = RUN_ALL_TESTS();
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
bool call(const std::string &service_name, MReq &req, MRes &res)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
std_msgs::Header * header(M &m)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
int main(int argc, char **argv)
ROSCPP_DECL bool waitForService(const std::string &service_name, int32_t timeout)