[Mockpp-commits] mockpp/mockpp/chaining ChainableMockMethod6.h,NONE,1.1 ChainableMockMethod0.h,1.2,1
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-10-29 18:17:38
|
Update of /cvsroot/mockpp/mockpp/mockpp/chaining In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11255/mockpp/chaining Modified Files: ChainableMockMethod0.h ChainableMockMethod1.h ChainableMockMethod2.h ChainableMockMethod3.h ChainableMockMethod4.h ChainableMockMethod5.h InvocationN.h Makefile.am Added Files: ChainableMockMethod6.h Log Message: provide up to 6 parameters --- NEW FILE: ChainableMockMethod6.h --- /** @file @brief Chainable Mock Method with 6 parameters. Generated with gen_chainablemethod_N.pl. $Id: ChainableMockMethod6.h,v 1.1 2005/10/29 18:17:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 2 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_ChainableMockMethod6_H #define MOCKPP_ChainableMockMethod6_H #include <mockpp/mockpp.h> #include <mockpp/ChainableMockObject.h> #include <mockpp/chaining/ChainableMockMethod.h> namespace mockpp { /** Common stuff to set up chainable mock method expectations with 6 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> class ChainableMockMethod6Common : public ChainableMockMethodCommon<R> { public: typedef Invocation6<P1, P2, P3, P4, P5, P6> InvocationType; typedef CoreMock<R, InvocationType> CoreMockType; typedef R ReturnType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod6Common(const String &name, ChainableMockObject *parent ) : ChainableMockMethodCommon<R>(name, parent) , coremock(name + MOCKPP_PCHAR("/coreMock"), this) { } protected: /** Returns the underlying coremock. * @return reference to the mock object */ CoreMockType & getCoreMock() const { return coremock; } public: typedef ChainingMockBuilder <ArgumentsMatchBuilder6<ReturnType, InvocationType> > Builder; /** Helper object to easily set up the chainable expectations. * @ingroup grp_controller */ class ChainerFor : public Builder { public: /** Construct the chainer object. * @meth pointer to according method mock. */ ChainerFor(ChainableMockMethod6Common &method) : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) { } }; private: mutable CoreMockType coremock; }; /** Set up a chainable mock method expectations with 6 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> class ChainableMockMethod6 : public ChainableMockMethod6Common<R, P1, P2, P3, P4, P5, P6> { public: typedef typename ChainableMockMethod6Common<R, P1, P2, P3, P4, P5, P6>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod6(const String &name, ChainableMockObject *parent ) : ChainableMockMethod6Common<R, P1, P2, P3, P4, P5, P6>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 * @param p6 mock method parameter 6 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6) const { InvocationType inv(this->getMethodName(), p1, p2, p3, p4, p5, p6); return this->getCoreMock().invoke(inv); } }; /** Set up a chainable mock method expectations with 6 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> class ChainableMockMethod6<void, P1, P2, P3, P4, P5, P6> : public ChainableMockMethod6Common<void, P1, P2, P3, P4, P5, P6> { public: typedef typename ChainableMockMethod6Common<void, P1, P2, P3, P4, P5, P6>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod6(const String &name, ChainableMockObject *parent ) : ChainableMockMethod6Common<void, P1, P2, P3, P4, P5, P6>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 * @param p5 mock method parameter 5 * @param p6 mock method parameter 6 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6) const { InvocationType inv(this->getMethodName(), p1, p2, p3, p4, p5, p6); this->getCoreMock().invoke(inv); } }; } // ns mockpp #endif // MOCKPP_ChainableMockMethod6_H Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/chaining/Makefile.am,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Makefile.am 27 Oct 2005 18:54:01 -0000 1.14 +++ Makefile.am 29 Oct 2005 18:17:30 -0000 1.15 @@ -15,6 +15,7 @@ ChainableMockMethod3.h \ ChainableMockMethod4.h \ ChainableMockMethod5.h \ + ChainableMockMethod6.h \ InvocationN.h EXTRA_DIST = \ Index: InvocationN.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/chaining/InvocationN.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- InvocationN.h 28 Oct 2005 20:35:13 -0000 1.2 +++ InvocationN.h 29 Oct 2005 18:17:30 -0000 1.3 @@ -548,6 +548,153 @@ }; +/** Hold invocations with 6 parameters + * @internal + */ +template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> +class Invocation6 : public Invocation +{ + public: + + enum { numParams = 6 }; + + typedef ConstraintSet6<P1, P2, P3, P4, P5, P6> ConstraintSetType; + + typedef P1 T1Type; + typedef P2 T2Type; + typedef P3 T3Type; + typedef P4 T4Type; + typedef P5 T5Type; + typedef P6 T6Type; + + /** Constructs the object + * @param name name of he object + * @param in_param1 parameter 1 + * @param in_param2 parameter 2 + * @param in_param3 parameter 3 + * @param in_param4 parameter 4 + * @param in_param5 parameter 5 + * @param in_param6 parameter 6 + */ + Invocation6( const String &name + , const P1 &in_param1 + , const P2 &in_param2 + , const P3 &in_param3 + , const P4 &in_param4 + , const P5 &in_param5 + , const P6 &in_param6) + : Invocation( name ) + , param1( in_param1 ) + , param2( in_param2 ) + , param3( in_param3 ) + , param4( in_param4 ) + , param5( in_param5 ) + , param6( in_param6 ) + { + } + +#ifdef MOCKPP_USE_INVOCATION_EQUALS + + /** Check if the object equals another invocation + * @param other the other invocation + * @return true: objects are equal + */ + virtual bool equals( const Invocation6<P1, P2, P3, P4, P5, P6> &other ) const + { + return invocationComparison(param1, other.param1) + && invocationComparison(param2, other.param2) + && invocationComparison(param3, other.param3) + && invocationComparison(param4, other.param4) + && invocationComparison(param5, other.param5) + && invocationComparison(param6, other.param6); + } + + /** Check if the object equals another invocation + * @param other the other invocation + * @return true: objects are equal + */ + bool equals( const InvocationBase &other ) const + { + MOCKPP_UNUSED(other); + return false; + } + +#endif // MOCKPP_USE_INVOCATION_EQUALS + + /** Returns an invocation parameter + * @return the invocation parameter 1 + */ + const P1 & getParameter1() const + { + return param1; + } + + /** Returns an invocation parameter + * @return the invocation parameter 2 + */ + const P2 & getParameter2() const + { + return param2; + } + + /** Returns an invocation parameter + * @return the invocation parameter 3 + */ + const P3 & getParameter3() const + { + return param3; + } + + /** Returns an invocation parameter + * @return the invocation parameter 4 + */ + const P4 & getParameter4() const + { + return param4; + } + + /** Returns an invocation parameter + * @return the invocation parameter 5 + */ + const P5 & getParameter5() const + { + return param5; + } + + /** Returns an invocation parameter + * @return the invocation parameter 6 + */ + const P6 & getParameter6() const + { + return param6; + } + + /** Returns a description of the parameters + * @return the description + */ + virtual String describeParameters() const + { + String fmt = MOCKPP_PCHAR("%1, %2, %3, %4, %5, %6"); + fmt << param1 + << param2 + << param3 + << param4 + << param5 + << param6; + return fmt; + } + + private: + + const P1 & param1; + const P2 & param2; + const P3 & param3; + const P4 & param4; + const P5 & param5; + const P6 & param6; +}; + + } // ns mockpp |