00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef MOCKPP_CHAININGMOCKOBJECTSUPPORT_H
00036 #define MOCKPP_CHAININGMOCKOBJECTSUPPORT_H
00037
00038
00039 #include <mockpp/mockpp.h>
00040
00041 #include <mockpp/Throwable.h>
00042
00043 #include <mockpp/util/AutoPointer.h>
00044
00045 #include <mockpp/constraint/And.h>
00046 #include <mockpp/constraint/Or.h>
00047 #include <mockpp/constraint/IsEqual.h>
00048 #include <mockpp/constraint/IsSame.h>
00049 #include <mockpp/constraint/IsNot.h>
00050 #include <mockpp/constraint/IsCloseTo.h>
00051 #include <mockpp/constraint/StringContains.h>
00052 #include <mockpp/constraint/StringStartsWith.h>
00053 #include <mockpp/constraint/StringEndsWith.h>
00054 #include <mockpp/constraint/IsInstanceOf.h>
00055 #include <mockpp/constraint/IsGreaterThan.h>
00056 #include <mockpp/constraint/IsGreaterOrEqual.h>
00057 #include <mockpp/constraint/IsLessThan.h>
00058 #include <mockpp/constraint/IsLessOrEqual.h>
00059 #include <mockpp/constraint/OutBound.h>
00060
00061 #include <mockpp/chaining/CoreMock.h>
00062
00063 #include <mockpp/stub/ThrowStub.h>
00064 #include <mockpp/stub/ReturnStub.h>
00065 #include <mockpp/stub/RandomStub.h>
00066 #include <mockpp/stub/ReturnObjectListStub.h>
00067
00068 #include <mockpp/matcher/TypelessMatcher.h>
00069
00070
00071 MOCKPP_NS_START
00072
00102 MOCKPP_API_DECL(TypelessConstraint::AP) any();
00103
00104
00110 MOCKPP_API_DECL(TypelessConstraint::AP) nothing();
00111
00112
00119 template <typename T>
00120 typename Constraint<T>::AP
00121 outBound( const T& op )
00122 {
00123 return new OutBound<T>( op );
00124 }
00125
00126
00133 template <typename T>
00134 typename Constraint<T>::AP
00135 eq( const T& op )
00136 {
00137 return new IsEqual<T>( op );
00138 }
00139
00140
00147 template <typename T>
00148 typename Constraint<T>::AP
00149 ne( const T& op )
00150 {
00151 return new IsNot<T>( new IsEqual<T>( op ) );
00152 }
00153
00154
00162 template <typename T>
00163 typename Constraint<T>::AP
00164 eq( const T &operand, const T &deviation )
00165 {
00166 return new IsCloseTo<T>( operand, deviation );
00167 }
00168
00169
00176 template <typename T>
00177 typename Constraint<T>::AP
00178 le( const T &value )
00179 {
00180 return new IsLessOrEqual<T>( value );
00181 }
00182
00183
00190 template <typename T>
00191 typename Constraint<T>::AP
00192 lt( const T &value )
00193 {
00194 return new IsLessThan<T>( value );
00195 }
00196
00197
00204 template <typename T>
00205 typename Constraint<T>::AP
00206 gt( const T &value )
00207 {
00208 return new IsGreaterThan<T>( value );
00209 }
00210
00211
00218 template <typename T>
00219 typename Constraint<T>::AP
00220 ge( const T &value )
00221 {
00222 return new IsGreaterOrEqual<T>( value );
00223 }
00224
00225
00232 template <typename T>
00233 typename Constraint<T>::AP
00234 same( const T &operand )
00235 {
00236 return new IsSame<T>( operand );
00237 }
00238
00239
00240 #ifndef MOCKPP_NO_RTTI
00241
00249 template <typename ROOT,
00250 typename DERIVED>
00251 typename Constraint<ROOT*>::AP
00252 isA( const DERIVED & )
00253 {
00254 return new IsInstanceOf<ROOT, DERIVED>();
00255 }
00256
00264 template <typename ROOT,
00265 typename DERIVED>
00266 typename Constraint<ROOT*>::AP
00267 isA()
00268 {
00269 return new IsInstanceOf<ROOT, DERIVED>();
00270 }
00271
00272 #endif // MOCKPP_NO_RTTI
00273
00274
00281 template <typename S>
00282 typename Constraint<S>::AP
00283 stringContains( const S &substring )
00284 {
00285 return new StringContains<S>( substring );
00286 }
00287
00288
00295 template <typename S>
00296 typename Constraint<S>::AP
00297 startsWith( const S &substring )
00298 {
00299 return new StringStartsWith<S>( substring );
00300 }
00301
00302
00309 template <typename S>
00310 typename Constraint<S>::AP
00311 endsWith( const S &substring )
00312 {
00313 return new StringEndsWith<S>( substring );
00314 }
00315
00316
00323 template <typename PCS>
00324 typename Constraint<MOCKPP_STL::basic_string<PCS> >::AP
00325 stringContains( const PCS *substring )
00326 {
00327 return new StringContains<MOCKPP_STL::basic_string<PCS> >( substring );
00328 }
00329
00330
00337 template <typename T>
00338 typename Constraint<T>::AP
00339 logic_not( const ConstraintHolder<T> &c )
00340 {
00341 return new IsNot<T>( c );
00342 }
00343
00344
00354 template <typename T>
00355 typename Constraint<T>::AP
00356 logic_and( const ConstraintHolder<T> &left,
00357 const ConstraintHolder<T> &right,
00358 bool shortcut = true )
00359 {
00360 return new And<T>( left, right, shortcut );
00361 }
00362
00363
00373 template <typename T>
00374 typename Constraint<T>::AP
00375 logic_or( const ConstraintHolder<T> &left,
00376 const ConstraintHolder<T> &right,
00377 bool shortcut = true )
00378 {
00379 return new Or<T>( left, right, shortcut );
00380 }
00381
00382
00389 template <typename T>
00390 typename TypelessStub<T>::AP returnValue( const T &o )
00391 {
00392 return new ReturnStub<T>( o );
00393 }
00394
00395
00402 template <typename R, typename T>
00403 typename TypelessStub<R>::AP randomValue( const T &max )
00404 {
00405 return new RandomStub<R, T>( max );
00406 }
00407
00408
00416 template <typename R, typename T>
00417 typename TypelessStub<R>::AP randomValue( const T &min, const T &max )
00418 {
00419 return new RandomStub<R, T>( min, max );
00420 }
00421
00422
00430 template <typename T,
00431 typename I >
00432 typename TypelessStub<T>::AP returnValue( I start, I end )
00433 {
00434 return new ReturnObjectListStub<T>( start, end );
00435 }
00436
00437
00443 MOCKPP_API_DECL(TypelessStub<void>::AP) isVoid( );
00444
00445
00452 template <typename R,
00453 typename T>
00454 typename TypelessStub<R>::AP throwException( const T &val )
00455 {
00456 return new ThrowStub<R>( make_throwable(val) );
00457 }
00458
00459
00465 MOCKPP_API_DECL(AutoPointer<TypelessMatcher>) once();
00466
00467
00473 MOCKPP_API_DECL(AutoPointer<TypelessMatcher>) atLeastOnce();
00474
00475
00481 MOCKPP_API_DECL(AutoPointer<TypelessMatcher>) unlimited();
00482
00483
00489 MOCKPP_API_DECL(AutoPointer<TypelessMatcher>) atMost( int expectedCount );
00490
00491
00497 MOCKPP_API_DECL(AutoPointer<TypelessMatcher>) atLeast(int expectedCount);
00498
00499
00505 MOCKPP_API_DECL(AutoPointer<TypelessMatcher>) exactly( int expectedCount );
00506
00507
00513 MOCKPP_API_DECL(AutoPointer<TypelessMatcher>) never();
00514
00515
00522 MOCKPP_API_DECL(AutoPointer<TypelessMatcher> never)( const String &errorMessage );
00523
00524
00525 MOCKPP_NS_END
00526
00527
00528 #include "OnConsecutiveCalls.h"
00529 #include "ReturnValueAndTrigger.h"
00530 #include "ReturnValueAndCall.h"
00531
00532
00536 #ifdef MOCKPP_IMPORT_ABBREVIATED
00537 using MOCKPP_NS::any;
00538 using MOCKPP_NS::nothing;
00539 using MOCKPP_NS::eq;
00540 using MOCKPP_NS::ne;
00541 using MOCKPP_NS::le;
00542 using MOCKPP_NS::ge;
00543 using MOCKPP_NS::gt;
00544 using MOCKPP_NS::lt;
00545 using MOCKPP_NS::same;
00546 #ifndef MOCKPP_NO_RTTI
00547 using MOCKPP_NS::isA;
00548 #endif
00549 using MOCKPP_NS::stringContains;
00550 using MOCKPP_NS::startsWith;
00551 using MOCKPP_NS::endsWith;
00552 using MOCKPP_NS::logic_not;
00553 using MOCKPP_NS::logic_and;
00554 using MOCKPP_NS::logic_or;
00555 using MOCKPP_NS::returnValue;
00556 using MOCKPP_NS::returnValueAndTrigger;
00557 using MOCKPP_NS::trigger;
00558 using MOCKPP_NS::returnValueAndCall;
00559 using MOCKPP_NS::call;
00560 using MOCKPP_NS::onConsecutiveCalls;
00561 using MOCKPP_NS::throwException;
00562 using MOCKPP_NS::once;
00563 using MOCKPP_NS::atLeastOnce;
00564 using MOCKPP_NS::atMost;
00565 using MOCKPP_NS::atLeast;
00566 using MOCKPP_NS::exactly;
00567 using MOCKPP_NS::never;
00568 using MOCKPP_NS::isVoid;
00569 using MOCKPP_NS::unlimited;
00570 using MOCKPP_NS::outBound;
00571 #endif
00572
00573
00574 #endif // MOCKPP_CHAININGMOCKOBJECTSUPPORT_H