21 #define ORO_TEST_OPERATION_CALLER 50 BOOST_CHECK_EQUAL( -1.0, m0() );
51 BOOST_CHECK_EQUAL( -2.0, m1(1) );
52 BOOST_CHECK_EQUAL( -3.0, m2(1, 2.0) );
53 BOOST_CHECK_EQUAL( -4.0, m3(1, 2.0,
true) );
54 BOOST_CHECK_EQUAL( -5.0, m4(1, 2.0,
true,
"hello") );
55 BOOST_CHECK_EQUAL( -6.0, m5(1, 2.0,
true,
"hello",5.0) );
56 BOOST_CHECK_EQUAL( -7.0, m6(1, 2.0,
true,
"hello",5.0,
'a') );
57 BOOST_CHECK_EQUAL( -8.0, m7(1, 2.0,
true,
"hello",5.0,
'a',7) );
59 BOOST_CHECK_THROW(m0e(), std::runtime_error);
71 OperationCaller<double(int,double,bool,std::string,float,char)> m6(
"m6", &
OperationsFixture::m6,
this, tc->engine(), caller->engine(),
OwnThread);
72 OperationCaller<double(int,double,bool,std::string,float,char,unsigned int)> m7(
"m7", &
OperationsFixture::m7,
this, tc->engine(), caller->engine(),
OwnThread);
76 BOOST_REQUIRE( tc->isRunning() );
77 BOOST_REQUIRE( caller->isRunning() );
78 BOOST_CHECK_EQUAL( -1.0, m0() );
79 BOOST_CHECK_EQUAL( -2.0, m1(1) );
80 BOOST_CHECK_EQUAL( -3.0, m2(1, 2.0) );
81 BOOST_CHECK_EQUAL( -4.0, m3(1, 2.0,
true) );
82 BOOST_CHECK_EQUAL( -5.0, m4(1, 2.0,
true,
"hello") );
83 BOOST_CHECK_EQUAL( -6.0, m5(1, 2.0,
true,
"hello",5.0) );
84 BOOST_CHECK_EQUAL( -7.0, m6(1, 2.0,
true,
"hello",5.0,
'a') );
85 BOOST_CHECK_EQUAL( -8.0, m7(1, 2.0,
true,
"hello",5.0,
'a',7) );
87 BOOST_CHECK_THROW( m0e(), std::runtime_error);
88 BOOST_REQUIRE( tc->inException() );
101 OperationCaller<double(int,double,bool,std::string,float,char,unsigned int)> m7(
"m7", &
OperationsFixture::m7,
this, 0, caller->engine());
106 BOOST_REQUIRE( tc->isRunning() );
107 BOOST_REQUIRE( caller->isRunning() );
114 SendHandle<double(int,double,bool,std::string,float,char)> h6 = m6.send(1, 2.0,
true,
"hello",5.0,
'a');
115 SendHandle<double(int,double,bool,std::string,float,char,unsigned int)> h7 = m7.send(1, 2.0,
true,
"hello",5.0,
'a',7);
120 BOOST_CHECK_EQUAL(
SendSuccess, h0.collect(retn) );
121 BOOST_CHECK_EQUAL( retn, -1.0 );
123 BOOST_CHECK_EQUAL( retn, -2.0 );
125 BOOST_CHECK_EQUAL( retn, -3.0 );
127 BOOST_CHECK_EQUAL( retn, -4.0 );
129 BOOST_CHECK_EQUAL( retn, -5.0 );
131 BOOST_CHECK_EQUAL( retn, -6.0 );
133 BOOST_CHECK_EQUAL( retn, -7.0 );
135 BOOST_CHECK_EQUAL( retn, -8.0 );
137 BOOST_CHECK_THROW( h0e.
collect(), std::runtime_error);
140 BOOST_CHECK_EQUAL(
SendSuccess, h0.collectIfDone(retn) );
141 BOOST_CHECK_EQUAL( retn, -1.0 );
142 BOOST_CHECK_EQUAL(
SendSuccess, h1.collectIfDone(retn) );
143 BOOST_CHECK_EQUAL( retn, -2.0 );
144 BOOST_CHECK_EQUAL(
SendSuccess, h2.collectIfDone(retn) );
145 BOOST_CHECK_EQUAL( retn, -3.0 );
146 BOOST_CHECK_EQUAL(
SendSuccess, h3.collectIfDone(retn) );
147 BOOST_CHECK_EQUAL( retn, -4.0 );
148 BOOST_CHECK_EQUAL(
SendSuccess, h4.collectIfDone(retn) );
149 BOOST_CHECK_EQUAL( retn, -5.0 );
150 BOOST_CHECK_EQUAL(
SendSuccess, h5.collectIfDone(retn) );
151 BOOST_CHECK_EQUAL( retn, -6.0 );
152 BOOST_CHECK_EQUAL(
SendSuccess, h6.collectIfDone(retn) );
153 BOOST_CHECK_EQUAL( retn, -7.0 );
154 BOOST_CHECK_EQUAL(
SendSuccess, h7.collectIfDone(retn) );
155 BOOST_CHECK_EQUAL( retn, -8.0 );
157 BOOST_CHECK_THROW( h0e.collectIfDone(), std::runtime_error);
160 BOOST_CHECK_EQUAL( -1.0, h0.ret() );
161 BOOST_CHECK_EQUAL( -2.0, h1.ret(1) );
162 BOOST_CHECK_EQUAL( -3.0, h2.ret(1, 2.0) );
163 BOOST_CHECK_EQUAL( -4.0, h3.ret(1, 2.0,
true) );
164 BOOST_CHECK_EQUAL( -5.0, h4.ret(1, 2.0,
true,
"hello") );
165 BOOST_CHECK_EQUAL( -6.0, h5.ret(1, 2.0,
true,
"hello",5.0) );
166 BOOST_CHECK_EQUAL( -7.0, h6.ret(1, 2.0,
true,
"hello",5.0,
'a') );
167 BOOST_CHECK_EQUAL( -8.0, h7.ret(1, 2.0,
true,
"hello",5.0,
'a',7) );
169 BOOST_CHECK_THROW( h0e.ret(), std::runtime_error);
171 BOOST_CHECK_EQUAL( -2.0, h1.ret() );
172 BOOST_CHECK_EQUAL( -3.0, h2.ret() );
173 BOOST_CHECK_EQUAL( -4.0, h3.ret() );
174 BOOST_CHECK_EQUAL( -5.0, h4.ret() );
175 BOOST_CHECK_EQUAL( -6.0, h5.ret() );
176 BOOST_CHECK_EQUAL( -7.0, h6.ret() );
177 BOOST_CHECK_EQUAL( -8.0, h7.ret() );
188 OperationCaller<double(int,double,bool,std::string,float,char)> m6(
"m6", &
OperationsFixture::m6,
this, tc->engine(), caller->engine(),
OwnThread);
189 OperationCaller<double(int,double,bool,std::string,float,char,unsigned int)> m7(
"m7", &
OperationsFixture::m7,
this, tc->engine(), caller->engine(),
OwnThread);
193 BOOST_REQUIRE( tc->isRunning() );
194 BOOST_REQUIRE( caller->isRunning() );
201 SendHandle<double(int,double,bool,std::string,float,char)> h6 = m6.send(1, 2.0,
true,
"hello",5.0,
'a');
202 SendHandle<double(int,double,bool,std::string,float,char,unsigned int)> h7 = m7.send(1, 2.0,
true,
"hello",5.0,
'a',7);
207 BOOST_CHECK_EQUAL(
SendSuccess, h0.collect(retn) );
208 BOOST_CHECK_EQUAL( retn, -1.0 );
210 BOOST_CHECK_EQUAL( retn, -2.0 );
212 BOOST_CHECK_EQUAL( retn, -3.0 );
214 BOOST_CHECK_EQUAL( retn, -4.0 );
216 BOOST_CHECK_EQUAL( retn, -5.0 );
218 BOOST_CHECK_EQUAL( retn, -6.0 );
220 BOOST_CHECK_EQUAL( retn, -7.0 );
222 BOOST_CHECK_EQUAL( retn, -8.0 );
224 BOOST_CHECK_THROW( h0e.
collect(), std::runtime_error);
225 BOOST_REQUIRE( tc->inException() );
226 BOOST_REQUIRE( tc->recover() && tc->start() );
227 BOOST_REQUIRE( tc->isRunning() );
230 BOOST_CHECK_EQUAL(
SendSuccess, h0.collectIfDone(retn) );
231 BOOST_CHECK_EQUAL( retn, -1.0 );
232 BOOST_CHECK_EQUAL(
SendSuccess, h1.collectIfDone(retn) );
233 BOOST_CHECK_EQUAL( retn, -2.0 );
234 BOOST_CHECK_EQUAL(
SendSuccess, h2.collectIfDone(retn) );
235 BOOST_CHECK_EQUAL( retn, -3.0 );
236 BOOST_CHECK_EQUAL(
SendSuccess, h3.collectIfDone(retn) );
237 BOOST_CHECK_EQUAL( retn, -4.0 );
238 BOOST_CHECK_EQUAL(
SendSuccess, h4.collectIfDone(retn) );
239 BOOST_CHECK_EQUAL( retn, -5.0 );
240 BOOST_CHECK_EQUAL(
SendSuccess, h5.collectIfDone(retn) );
241 BOOST_CHECK_EQUAL( retn, -6.0 );
242 BOOST_CHECK_EQUAL(
SendSuccess, h6.collectIfDone(retn) );
243 BOOST_CHECK_EQUAL( retn, -7.0 );
244 BOOST_CHECK_EQUAL(
SendSuccess, h7.collectIfDone(retn) );
245 BOOST_CHECK_EQUAL( retn, -8.0 );
247 BOOST_CHECK_THROW( h0e.collectIfDone(), std::runtime_error);
249 BOOST_REQUIRE( tc->isRunning() );
252 BOOST_CHECK_EQUAL( -1.0, h0.ret() );
253 BOOST_CHECK_EQUAL( -2.0, h1.ret(1) );
254 BOOST_CHECK_EQUAL( -3.0, h2.ret(1, 2.0) );
255 BOOST_CHECK_EQUAL( -4.0, h3.ret(1, 2.0,
true) );
256 BOOST_CHECK_EQUAL( -5.0, h4.ret(1, 2.0,
true,
"hello") );
257 BOOST_CHECK_EQUAL( -6.0, h5.ret(1, 2.0,
true,
"hello",5.0) );
258 BOOST_CHECK_EQUAL( -7.0, h6.ret(1, 2.0,
true,
"hello",5.0,
'a') );
259 BOOST_CHECK_EQUAL( -8.0, h7.ret(1, 2.0,
true,
"hello",5.0,
'a',7) );
261 BOOST_CHECK_THROW( h0e.ret(), std::runtime_error);
262 BOOST_REQUIRE( tc->isRunning() );
264 BOOST_CHECK_EQUAL( -2.0, h1.ret() );
265 BOOST_CHECK_EQUAL( -3.0, h2.ret() );
266 BOOST_CHECK_EQUAL( -4.0, h3.ret() );
267 BOOST_CHECK_EQUAL( -5.0, h4.ret() );
268 BOOST_CHECK_EQUAL( -6.0, h5.ret() );
269 BOOST_CHECK_EQUAL( -7.0, h6.ret() );
270 BOOST_CHECK_EQUAL( -8.0, h7.ret() );
285 BOOST_CHECK( !m0.
ready() );
286 BOOST_CHECK( !m1.
ready() );
287 BOOST_CHECK( !m2.
ready() );
293 BOOST_CHECK( to->addLocalOperation(m0) );
294 BOOST_CHECK( !m0.
ready() );
297 BOOST_CHECK( m0.
ready() );
300 BOOST_CHECK( to->addLocalOperation(m0) );
301 BOOST_CHECK( to->addLocalOperation(m0) );
302 BOOST_CHECK( to->addLocalOperation(m1) );
303 BOOST_CHECK( to->addLocalOperation(m2) );
307 BOOST_CHECK( mm0.getOperationCallerImpl() );
308 BOOST_CHECK( mm0.ready() );
312 mm1 = to->getLocalOperation(
"m1");
313 BOOST_CHECK( mm1.getOperationCallerImpl() );
314 BOOST_CHECK( mm1.ready() );
317 BOOST_CHECK( mm2.getOperationCallerImpl() );
318 BOOST_CHECK( mm2.ready() );
321 BOOST_CHECK_EQUAL( -1.0, mm0() );
323 BOOST_CHECK_EQUAL( -2.0, mm1(1) );
324 BOOST_CHECK_EQUAL( -3.0, mm2(1, 2.0) );
329 BOOST_CHECK(to->addLocalOperation( ovoid ) ==
true);
331 BOOST_CHECK(to->addLocalOperation( ovoid ) ==
true);
335 mvoid = to->getLocalOperation(
"m1");
336 BOOST_CHECK( mvoid.
ready() == false );
338 mvoid = to->getLocalOperation(
"m2");
339 BOOST_CHECK( mvoid.ready() == false );
341 mvoid = to->getLocalOperation(
"m0");
342 BOOST_CHECK( mvoid.ready() == false );
344 mvoid = to->getLocalOperation(
"voidm");
345 BOOST_CHECK( mvoid.ready() == false );
362 BOOST_CHECK_EQUAL( -3.3, m0r() );
363 BOOST_CHECK_EQUAL( -3.3, m0cr() );
366 BOOST_CHECK_EQUAL( 5.3*2, m1r(value) );
367 BOOST_CHECK_EQUAL( 5.3*2, value );
368 BOOST_CHECK_EQUAL( 5.3, m1cr(5.3) );
381 BOOST_CHECK_EQUAL( -3.3, m0r() );
382 BOOST_CHECK_EQUAL( -3.3, m0cr() );
385 BOOST_CHECK_EQUAL( 5.3*2, m1r(value) );
386 BOOST_CHECK_EQUAL( 5.3*2, value );
387 BOOST_CHECK_EQUAL( 5.3, m1cr(5.3) );
412 BOOST_CHECK( to->addOperationDS( wp.
get(), meth0).doc(
"desc" ).ready() );
413 BOOST_CHECK( to->addOperationDS( wp.
get(), meth1).doc(
"desc").arg(
"a1",
"d1" ).ready() );
420 BOOST_CHECK( c0.
call() );
421 BOOST_CHECK_EQUAL( -1.0, ret );
423 BOOST_CHECK( c1.
call() );
424 BOOST_CHECK_EQUAL( -2.0, ret );
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
double m6(int i, double d, bool c, std::string s, float f, char h)
BOOST_AUTO_TEST_CASE(testClientThreadOperationCaller)
#define BOOST_AUTO_TEST_SUITE_END()
double m5(int i, double d, bool c, std::string s, float f)
boost::shared_ptr< Service > shared_ptr
double m4(int i, double d, bool c, std::string s)
The SendHandle is used to collect the result values of an asynchronous invocation. The template argument Signature must have the same type as the method being invoked.
double m1cr(const double &a)
boost::shared_ptr< Service > ServicePtr
OperationCallerC & ret(base::AttributeBase *r)
double m3(int i, double d, bool c)
Operation & calls(boost::function< Signature > func, ExecutionThread et=ClientThread, ExecutionEngine *ownerEngine=NULL)
DataSource< T >::result_t get() const
double m7(int i, double d, bool c, std::string s, float f, char h, unsigned int st)
SendStatus collect() const
double m2(int i, double d)