mockpp-commits Mailing List for Mock Objects for C++ (Page 27)
Brought to you by:
ewald-arnold
You can subscribe to this list here.
2005 |
Jan
|
Feb
(17) |
Mar
(178) |
Apr
(119) |
May
(60) |
Jun
(3) |
Jul
(60) |
Aug
(16) |
Sep
(55) |
Oct
(156) |
Nov
(136) |
Dec
(255) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(98) |
Feb
(8) |
Mar
(57) |
Apr
(43) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
Update of /cvsroot/mockpp/mockpp/mockpp/chaining In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27524/mockpp/chaining Modified Files: ChainableMockMethod0.h ChainableMockMethod1.h ChainableMockMethod2.h ChainableMockMethod3.h ChainableMockMethod4.h ChainableMockMethod5.h InvocationN.h Log Message: cleanup |
From: Ewald A. <ewa...@us...> - 2005-10-28 20:35:24
|
Update of /cvsroot/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27524 Modified Files: Makefile.am Log Message: cleanup Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/Makefile.am,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- Makefile.am 8 Oct 2005 17:52:13 -0000 1.30 +++ Makefile.am 28 Oct 2005 20:35:13 -0000 1.31 @@ -18,7 +18,8 @@ README \ TODO \ Makefile.cvs \ - mockpp.lsm + mockpp.lsm \ + gen_files_N.sh CLEANFILES = *.~* *.~~* *~ cachegrind.out.* |
From: Ewald A. <ewa...@us...> - 2005-10-28 20:35:24
|
Update of /cvsroot/mockpp/mockpp/mockpp/docs/en In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27524/mockpp/docs/en Modified Files: Makefile.am dev_advanced_jmock.docbook Log Message: cleanup Index: dev_advanced_jmock.docbook =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/docs/en/dev_advanced_jmock.docbook,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- dev_advanced_jmock.docbook 1 Oct 2005 16:38:46 -0000 1.13 +++ dev_advanced_jmock.docbook 28 Oct 2005 20:35:14 -0000 1.14 @@ -215,7 +215,7 @@ <para>For a similar reason there is another templated function named <function>isEqualComparison</function>. Both functions are useful if you need to compare objects but can't or don't want to -implement the according <function>operator==</function>. +implement the according <function>operator==</function>.</para> <para> <note> Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/docs/en/Makefile.am,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- Makefile.am 26 Sep 2005 18:25:10 -0000 1.31 +++ Makefile.am 28 Oct 2005 20:35:14 -0000 1.32 @@ -20,7 +20,6 @@ test -f mockpp-$(VERSION)-handbook.zip && mv mockpp-$(VERSION)-handbook.zip $(top_builddir) rm -r mockpp-$(VERSION)-handbook - doc: html-files pdf-files ################################################################ @@ -78,7 +77,7 @@ htmldir = $(pkgdatadir)/html -install-data-hook: +install-data-hook: doc $(mkdir_p) $(htmldir)/handbook/common $(mkdir_p) $(htmldir)/handbook/images/callouts $(INSTALL) var/*.html $(htmldir)/handbook |
From: Ewald A. <ewa...@us...> - 2005-10-28 19:10:47
|
Update of /cvsroot/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8847 Modified Files: ChangeLog Added Files: gen_files_N.sh Log Message: basic file set working --- NEW FILE: gen_files_N.sh --- #!/bin/sh echo parameter: $1 ( cd mockpp/chaining ; ./gen_invocation_N.pl $1 ) ( cd mockpp/chaining ; ./gen_chainablemethod_N.pl $1 ) ( cd mockpp ; ./gen_responsevector_N.pl $1 ) ( cd mockpp ; ./gen_visitablemethod_N.pl $1 ) ( cd mockpp/builder ; ./gen_argumentsmatchbuilder_N.pl $1 ) Index: ChangeLog =================================================================== RCS file: /cvsroot/mockpp/mockpp/ChangeLog,v retrieving revision 1.71 retrieving revision 1.72 diff -u -d -r1.71 -r1.72 --- ChangeLog 19 Oct 2005 20:53:22 -0000 1.71 +++ ChangeLog 28 Oct 2005 19:10:39 -0000 1.72 @@ -7,6 +7,9 @@ - fixes for g++ 4.0 - format boolean as "true" istead "1" + - created generator scripts to build classes based on increasing numbers + of parameters to enable methods with more than 5 parameters + - added template based classes to mock methods (chainable and visitable) 2005-10-11 1.9.5: |
From: Ewald A. <ewa...@us...> - 2005-10-28 19:04:14
|
Update of /cvsroot/mockpp/mockpp/mockpp/builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7258/mockpp/builder Modified Files: ArgumentsMatchBuilder.h Makefile.am Added Files: ArgumentsMatchBuilderN.h gen_argumentsmatchbuilder_N.pl Log Message: basic file set working --- NEW FILE: gen_argumentsmatchbuilder_N.pl --- #!/usr/bin/perl -w # # $Id: gen_argumentsmatchbuilder_N.pl,v 1.1 2005/10/28 19:04:04 ewald-arnold Exp $ use English; if ($#ARGV < 0) { print "Usage: perl gen_invocation_N <number of arguments>\n"; exit; } $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } open OUT, ">ArgumentsMatchBuilderN.h"; print OUT "/** \@file \@internal NOT INTENDED FOR PUBLIC INCLUSION \@brief Generated with gen_argumentsmatchbuilder_N.pl. \$I" . "d: InvocationN.h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ /************************************************************************** begin : Sun Aug 22 2004 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_ARGUMENTSMATCHBUILDER_N_H #define MOCKPP_ARGUMENTSMATCHBUILDER_N_H //#include <mockpp/builder/ArgumentsMatchBuilder.h> namespace mockpp { "; for ($numArgs = 1; $numArgs <= $totalNumArgs; ++$numArgs) { $templateParms = ""; $templateParms_colon = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $templateParms .= ", "; } $templateParms .= "typename P$i"; } if ($numArgs > 0) { $templateParms_colon = ", " . $templateParms; } $templateArgs_colon = ""; $_ = $templateParms; s/typename //g; $templateArgs = $_; if ($numArgs > 0) { $templateArgs_colon = ", ". $templateArgs; } $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $parms .= ", "; } $parms .= "const P$i &p$i"; } $percentParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $percentParms .= ", "; } $percentParms .= "%$i"; } $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $holderParms .= ", "; } $holderParms .= "const ConstraintHolder<P$i> &p$i"; } $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $args .= ", "; } $args .= "p$i"; } $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $boundArgs .= ", "; } $boundArgs .= "args->a$i"; } $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $copyParms .= ", "; } $copyParms .= "P$i ia$i"; } $hArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $hArgs .= ", "; } $hArgs .= "h$i"; } $initArgs = ""; if ($numArgs > 0) { $initArgs = ":"; } for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $initArgs .= ", "; } $initArgs .= "p$i(ip$i)"; } $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argTypes .= "typedef P$i p". ($i+1) . "_type; "; } print "Creating ArgumentsMatchBuilder" . $numArgs ."\n"; print OUT " /** Build a matcher for an invocation with " . $numArgs ." argument. * \@ingroup grp_chainer * \@internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder" . $numArgs ." : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType;"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " typedef typename I::T" .$p . "Type P" .$p . ";"; } print OUT " typedef ConstraintSet" . $numArgs ."<" . $templateArgs . "> ConstraintSetType; /** Adds another matcher. * \@param matcher the matcher object * \@return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for " . $numArgs ." arguments. * \@ingroup grp_chainer"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param cons" .$p . " pointer to the constraint for method parameter " .$p; } print OUT " * \@return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1"; for($p = 2; $p <= $numArgs; ++$p) { print OUT " , const ConstraintHolder<P" .$p . "> &p" .$p; } print OUT " ) { return with_cs( ConstraintSetType( " . $args . " ) ); } protected: /** Indicate a matcher for a set of arguments. * \@param constraintset constraint set * \@return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; "; } print OUT " } // ns mockpp #endif // MOCKPP_ARGUMENTSMATCHBUILDER_N_H "; close OUT; Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/builder/Makefile.am,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Makefile.am 19 Sep 2005 18:34:35 -0000 1.9 +++ Makefile.am 28 Oct 2005 19:04:04 -0000 1.10 @@ -1,10 +1,19 @@ INCLUDES = $(all_includes) -I$(top_srcdir) -I$(top_builddir) $(EA_EXTRA_INC) DEFAULT_INCLUDES = $(INCLUDES) -libbuilderinclude_HEADERS = ArgumentsMatchBuilder.h BuilderNamespace.h IdentityBuilder.h InvocationMockerBuilder.h MatchBuilder.h StubBuilder.h +libbuilderinclude_HEADERS = ArgumentsMatchBuilder.h \ + ArgumentsMatchBuilderN.h \ + BuilderNamespace.h \ + IdentityBuilder.h \ + InvocationMockerBuilder.h \ + MatchBuilder.h \ + StubBuilder.h libbuilderincludedir = $(includedir)/mockpp/builder +EXTRA_DIST = \ + gen_argumentsmatchbuilder_N.pl + CLEANFILES = *.~* *.~~* *~ *.old noinst_LTLIBRARIES = libbuilder.la --- NEW FILE: ArgumentsMatchBuilderN.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_argumentsmatchbuilder_N.pl. $Id: ArgumentsMatchBuilderN.h,v 1.1 2005/10/28 19:04:04 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sun Aug 22 2004 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_ARGUMENTSMATCHBUILDER_N_H #define MOCKPP_ARGUMENTSMATCHBUILDER_N_H //#include <mockpp/builder/ArgumentsMatchBuilder.h> namespace mockpp { /** Build a matcher for an invocation with 1 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder1 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef ConstraintSet1<P1> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 1 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 ) { return with_cs( ConstraintSetType( p1 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; /** Build a matcher for an invocation with 2 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder2 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef typename I::T2Type P2; typedef ConstraintSet2<P1, P2> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 2 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @param cons2 pointer to the constraint for method parameter 2 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 , const ConstraintHolder<P2> &p2 ) { return with_cs( ConstraintSetType( p1, p2 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; /** Build a matcher for an invocation with 3 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder3 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef typename I::T2Type P2; typedef typename I::T3Type P3; typedef ConstraintSet3<P1, P2, P3> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 3 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @param cons2 pointer to the constraint for method parameter 2 * @param cons3 pointer to the constraint for method parameter 3 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 , const ConstraintHolder<P2> &p2 , const ConstraintHolder<P3> &p3 ) { return with_cs( ConstraintSetType( p1, p2, p3 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; /** Build a matcher for an invocation with 4 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder4 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef typename I::T2Type P2; typedef typename I::T3Type P3; typedef typename I::T4Type P4; typedef ConstraintSet4<P1, P2, P3, P4> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 4 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @param cons2 pointer to the constraint for method parameter 2 * @param cons3 pointer to the constraint for method parameter 3 * @param cons4 pointer to the constraint for method parameter 4 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 , const ConstraintHolder<P2> &p2 , const ConstraintHolder<P3> &p3 , const ConstraintHolder<P4> &p4 ) { return with_cs( ConstraintSetType( p1, p2, p3, p4 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; /** Build a matcher for an invocation with 5 argument. * @ingroup grp_chainer * @internal */ template <typename R, // Returntype typename I> // Invocation class ArgumentsMatchBuilder5 : public MatchBuilder<R,I> { public: typedef R ReturnType; typedef I InvocationType; typedef typename I::T1Type P1; typedef typename I::T2Type P2; typedef typename I::T3Type P3; typedef typename I::T4Type P4; typedef typename I::T5Type P5; typedef ConstraintSet5<P1, P2, P3, P4, P5> ConstraintSetType; /** Adds another matcher. * @param matcher the matcher object * @return the builder object */ virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; /** Indicate a matcher for 5 arguments. * @ingroup grp_chainer * @param cons1 pointer to the constraint for method parameter 1 * @param cons2 pointer to the constraint for method parameter 2 * @param cons3 pointer to the constraint for method parameter 3 * @param cons4 pointer to the constraint for method parameter 4 * @param cons5 pointer to the constraint for method parameter 5 * @return the builder object */ MatchBuilder<R, I>& with( const ConstraintHolder<P1> &p1 , const ConstraintHolder<P2> &p2 , const ConstraintHolder<P3> &p3 , const ConstraintHolder<P4> &p4 , const ConstraintHolder<P5> &p5 ) { return with_cs( ConstraintSetType( p1, p2, p3, p4, p5 ) ); } protected: /** Indicate a matcher for a set of arguments. * @param constraintset constraint set * @return the builder object */ virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; }; } // ns mockpp #endif // MOCKPP_ARGUMENTSMATCHBUILDER_N_H Index: ArgumentsMatchBuilder.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/builder/ArgumentsMatchBuilder.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- ArgumentsMatchBuilder.h 26 Oct 2005 20:04:29 -0000 1.29 +++ ArgumentsMatchBuilder.h 28 Oct 2005 19:04:04 -0000 1.30 @@ -50,6 +50,7 @@ namespace mockpp { + /** Build a matcher for an invocation with no arguments. * @ingroup grp_chainer * @internal @@ -89,242 +90,12 @@ }; -/** Build a matcher for an invocation with 1 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder1 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef ConstraintSet1<T1> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 1 argument. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for the method parameter - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1 ) - { - return with_cs( ConstraintSetType( cons1 ) ); - } - - protected: - - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; - - -/** Build a matcher for an invocation with 2 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder2 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef typename I::T2Type T2; - typedef ConstraintSet2<T1, T2> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 2 arguments. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for method parameter 1 - * @param cons2 pointer to the constraint for method parameter 2 - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1, - const ConstraintHolder<T2> &cons2 ) - { - return with_cs( ConstraintSetType( cons1, cons2 ) ); - } - - protected: - - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; - - -/** Build a matcher for an invocation with 3 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder3 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef typename I::T2Type T2; - typedef typename I::T3Type T3; - typedef ConstraintSet3<T1, T2, T3> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 3 arguments. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for method parameter 1 - * @param cons2 pointer to the constraint for method parameter 2 - * @param cons3 pointer to the constraint for method parameter 3 - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1, - const ConstraintHolder<T2> &cons2, - const ConstraintHolder<T3> &cons3 ) - { - return with_cs( ConstraintSetType( cons1, cons2, cons3 ) ); - } - - protected: - - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; - - -/** Build a matcher for an invocation with 4 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder4 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef typename I::T2Type T2; - typedef typename I::T3Type T3; - typedef typename I::T4Type T4; - typedef ConstraintSet4<T1, T2, T3, T4> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 4 arguments. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for method parameter 1 - * @param cons2 pointer to the constraint for method parameter 2 - * @param cons3 pointer to the constraint for method parameter 3 - * @param cons4 pointer to the constraint for method parameter 4 - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1, - const ConstraintHolder<T2> &cons2, - const ConstraintHolder<T3> &cons3, - const ConstraintHolder<T4> &cons4 ) - { - return with_cs( ConstraintSetType( cons1, cons2, cons3, cons4 ) ); - } - - protected: - - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; - - -/** Build a matcher for an invocation with 5 argument. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilder5 : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef typename I::T1Type T1; - typedef typename I::T2Type T2; - typedef typename I::T3Type T3; - typedef typename I::T4Type T4; - typedef typename I::T5Type T5; - typedef ConstraintSet5<T1, T2, T3, T4, T5> ConstraintSetType; - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for 5 arguments. - * @ingroup grp_chainer - * @param cons1 pointer to the constraint for method parameter 1 - * @param cons2 pointer to the constraint for method parameter 2 - * @param cons3 pointer to the constraint for method parameter 3 - * @param cons4 pointer to the constraint for method parameter 4 - * @param cons5 pointer to the constraint for method parameter 5 - * @return the builder object - */ - MatchBuilder<R, I>& with( const ConstraintHolder<T1> &cons1, - const ConstraintHolder<T2> &cons2, - const ConstraintHolder<T3> &cons3, - const ConstraintHolder<T4> &cons4, - const ConstraintHolder<T5> &cons5 ) - { - return with_cs( ConstraintSetType( cons1, cons2, cons3, cons4, cons5 ) ); - } +} // namespace mockpp - protected: - /** Indicate a matcher for a set of arguments. - * @param constraintset constraint set - * @return the builder object - */ - virtual MatchBuilder<R, I>& with_cs( const ConstraintSetType &constraintset ) = 0; -}; +#endif // MOCKPP_ARGUMENTSMATCHBUILDER_H -} // namespace mockpp +#include "ArgumentsMatchBuilderN.h" -#endif // MOCKPP_ARGUMENTSMATCHBUILDER_H |
From: Steven W. <nar...@gm...> - 2005-10-28 18:12:23
|
in the doc, the 'MOCKPP_CHAINER_FOR(...) chainer (hostObject)' do the declearation and initialization of a chainer in one statement. but, i often need to seperate it, that is, declare a chainer in a testing class's declaration section and initialize the chainer in some other place. how can i do it? thanks. -- steven woody (id: narke) Stills Photographer: You know double-O-7? Bob: He drinks martinis, but all right. - Lost in Translation (2003) |
From: Ewald A. <ewa...@us...> - 2005-10-27 18:56:16
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9549/mockpp Modified Files: gen_responsevector_N.pl VisitableMockObject_template.h Log Message: wrong params Index: VisitableMockObject_template.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/VisitableMockObject_template.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- VisitableMockObject_template.h 26 Oct 2005 20:43:31 -0000 1.27 +++ VisitableMockObject_template.h 27 Oct 2005 18:56:07 -0000 1.28 @@ -93,8 +93,10 @@ std::vector<unsigned> counter; }; + #endif // DOXYGEN_SHOULD_SKIP_THIS + } // namespace mockpp Index: gen_responsevector_N.pl =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/gen_responsevector_N.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gen_responsevector_N.pl 26 Oct 2005 20:05:07 -0000 1.1 +++ gen_responsevector_N.pl 27 Oct 2005 18:56:07 -0000 1.2 @@ -196,10 +196,10 @@ {"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " - const ConstraintHolder<P" . $p . "> p" . $p . " = new IsEqual<P" . $p . ">(p" . $p . ");" } + const ConstraintHolder<P" . $p . "> h" . $p . " = new IsEqual<P" . $p . ">(p" . $p . ");" } print OUT " - add(t, " . $args . ", count); + add(t, " . $hArgs . ", count); } /** Adds a throwable. @@ -226,7 +226,7 @@ typename mockpp::Constraint<P" . $p . ">::AP cons" . $p . " (p" . $p . ");"; } for($p = 1; $p <= $numArgs; ++$p) { print OUT " - p" . $p . "vec.push_back(cons" . $p . ".release());"; } + t" . $p . "vec.push_back(cons" . $p . ".release());"; } print OUT " } @@ -272,6 +272,7 @@ && t" . $p . "vec[i]->eval(p" . $p . ")"; } print OUT " + ) { if (tvec.at(i) == 0) return false; @@ -298,7 +299,7 @@ /** Class returning a throwable depending on the parameters * passed to a method. */ -template <" . $templateParms . "> +template <typename R, " . $templateParms . "> class ResponseVector" . $numArgs . " : public ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> { public: @@ -340,7 +341,7 @@ void add(Throwable *t,"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " - const ConstraintHolder<P" . $p . "> &p" . $p . ",";} + const ConstraintHolder<P" . $p . "> &p" . $p . ","; } print OUT " unsigned count) @@ -429,6 +430,7 @@ && this->t" . $p . "vec[i]->eval(p" . $p . ")"; } print OUT " + ) { if (this->tvec.at(i) != 0) return false; |
From: Ewald A. <ewa...@us...> - 2005-10-27 18:54:10
|
Update of /cvsroot/mockpp/mockpp/mockpp/chaining In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8932/mockpp/chaining Modified Files: Invocation.h Makefile.am Added Files: InvocationN.h gen_invocation_N.pl Log Message: basic file set working --- NEW FILE: gen_invocation_N.pl --- #!/usr/bin/perl -w # # $Id: gen_invocation_N.pl,v 1.1 2005/10/27 18:54:01 ewald-arnold Exp $ use English; if ($#ARGV < 0) { print "Usage: perl gen_invocation_N <number of arguments>\n"; exit; } $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } open OUT, ">InvocationN.h"; print OUT "/** \@file \@internal NOT INTENDED FOR PUBLIC INCLUSION \@brief Generated with gen_invocation_N.pl. \$I" . "d: InvocationN.h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ /************************************************************************** begin : Thu Aug 24 2004 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_INVOCATION_N_H #define MOCKPP_INVOCATION_N_H //#include <mockpp/chaining/Invocation.h> namespace mockpp { "; for ($numArgs = 1; $numArgs <= $totalNumArgs; ++$numArgs) { $templateParms = ""; $templateParms_colon = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $templateParms .= ", "; } $templateParms .= "typename P$i"; } if ($numArgs > 0) { $templateParms_colon = ", " . $templateParms; } $templateArgs_colon = ""; $_ = $templateParms; s/typename //g; $templateArgs = $_; if ($numArgs > 0) { $templateArgs_colon = ", ". $templateArgs; } $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $parms .= ", "; } $parms .= "const P$i &p$i"; } $percentParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $percentParms .= ", "; } $percentParms .= "%$i"; } $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $holderParms .= ", "; } $holderParms .= "const ConstraintHolder<P$i> &p$i"; } $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $args .= ", "; } $args .= "p$i"; } $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $boundArgs .= ", "; } $boundArgs .= "args->a$i"; } $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $copyParms .= ", "; } $copyParms .= "P$i ia$i"; } $hArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $hArgs .= ", "; } $hArgs .= "h$i"; } $initArgs = ""; if ($numArgs > 0) { $initArgs = ":"; } for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $initArgs .= ", "; } $initArgs .= "p$i(ip$i)"; } $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argTypes .= "typedef P$i p". ($i+1) . "_type; "; } print "Creating Invocation" . $numArgs ."\n"; print OUT " /** Hold invocations with " . $numArgs . " parameters * \@internal */ template <" . $templateParms . "> class Invocation" . $numArgs . " : public Invocation { public: enum { numParams = " . $numArgs . " }; typedef ConstraintSet" . $numArgs . "<" . $templateArgs . "> ConstraintSetType; "; for($p = 1; $p <= $numArgs; ++$p) { print OUT " typedef P" . $p . " T" . $p . "Type;"; } print OUT " /** Constructs the object * \@param name name of he object"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param in_param" . $p . " parameter " . $p ; } print OUT " */ Invocation" . $numArgs . "( const String &name"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " , const P" . $p . " &in_param" . $p; } print OUT ") : Invocation( name )"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " , param" . $p . "( in_param" . $p . " )"; } print OUT " { } #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 Invocation" . $numArgs . "<" . $templateArgs . "> &other ) const { return invocationComparison(param1, other.param1)"; for($p = 2; $p <= $numArgs; ++$p) { print OUT " && invocationComparison(param" . $p . ", other.param" . $p . ")";} print OUT "; } /** 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 "; for($p = 1; $p <= $numArgs; ++$p) { print OUT " /** Returns an invocation parameter * \@return the invocation parameter " . $p . " */ const P" . $p . " & getParameter" . $p . "() const { return param" . $p . "; } "; } print OUT " /** Returns a description of the parameters * \@return the description */ virtual String describeParameters() const { String fmt = MOCKPP_PCHAR(\"" . $percentParms . "\"); fmt << param1"; for($p = 2; $p <= $numArgs; ++$p) { print OUT " << param" .$p; } print OUT "; return fmt; } private: "; for($p = 1; $p <= $numArgs; ++$p) { print OUT " const P" . $p . " & param" .$p . ";"; } print OUT " }; " } print OUT " } // ns mockpp #endif // MOCKPP_INVOCATION_N_H "; close OUT; Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/chaining/Makefile.am,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Makefile.am 25 Oct 2005 20:19:31 -0000 1.13 +++ Makefile.am 27 Oct 2005 18:54:01 -0000 1.14 @@ -14,10 +14,12 @@ ChainableMockMethod2.h \ ChainableMockMethod3.h \ ChainableMockMethod4.h \ - ChainableMockMethod5.h + ChainableMockMethod5.h \ + InvocationN.h EXTRA_DIST = \ - gen_chainablemethod_N.pl + gen_chainablemethod_N.pl \ + gen_invocation_N.pl libchainingincludedir = $(includedir)/mockpp/chaining Index: Invocation.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/chaining/Invocation.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- Invocation.h 17 Oct 2005 19:11:47 -0000 1.17 +++ Invocation.h 27 Oct 2005 18:54:01 -0000 1.18 @@ -156,518 +156,10 @@ }; -///////////////////////////////////////////////////////////////////// - - -/** Hold invocations with 1 parameters - * @internal - */ -template <typename T1> -class Invocation1 : public Invocation -{ - public: - - enum { numParams = 1 }; - - typedef ConstraintSet1<T1> ConstraintSetType; - typedef T1 T1Type; - - /** Constructs the object - * @param name name of he object - * @param in_param1 parameter 1 - */ - Invocation1( const String &name, - const T1 &in_param1 ) - : Invocation( name) - , param1( in_param1 ) - { - } - -#ifdef MOCKPP_USE_INVOCATION_EQUALS - - /** Check if the object equals another invocation - * @param other the other invocation - * @return true: objects are equal - */ - bool equals( const Invocation1<T1> &other ) const - { - return invocationComparison(param1, other.param1); - } - - /** 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 - */ - const T1 & getParameter1() const - { - return param1; - } - - /** Returns a description of the parameters - * @return the description - */ - virtual String describeParameters() const - { - String fmt = MOCKPP_PCHAR("%1"); - fmt << param1; - return fmt; - } - - private: - - const T1 & param1; -}; - - -///////////////////////////////////////////////////////////////////// - - -/** Hold invocations with 2 parameters - * @internal - */ -template <typename T1, typename T2> -class Invocation2 : public Invocation -{ - public: - - enum { numParams = 2 }; - - typedef ConstraintSet2<T1, T2> ConstraintSetType; - typedef T1 T1Type; - typedef T2 T2Type; - - /** Constructs the object - * @param name name of he object - * @param in_param1 parameter 1 - * @param in_param2 parameter 2 - */ - Invocation2( const String &name, - const T1 &in_param1, - const T2 &in_param2 ) - : Invocation( name ) - , param1( in_param1 ) - , param2( in_param2 ) - { - } - -#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 Invocation2<T1, T2> &other ) const - { - return invocationComparison(param1, other.param1) - && invocationComparison(param2, other.param2); - } - - /** 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 - */ - const T1 & getParameter1() const - { - return param1; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T2 & getParameter2() const - { - return param2; - } - - /** Returns a description of the parameters - * @return the description - */ - virtual String describeParameters() const - { - String fmt = MOCKPP_PCHAR("%1, %2"); - fmt << param1 << param2; - return fmt; - } - - private: - - const T1 & param1; - const T2 & param2; -}; - - -///////////////////////////////////////////////////////////////////// - - -/** Hold invocations with 3 parameters - * @internal - */ -template <typename T1, typename T2, typename T3> -class Invocation3 : public Invocation -{ - public: - - enum { numParams = 3 }; - - typedef ConstraintSet3<T1, T2, T3> ConstraintSetType; - typedef T1 T1Type; - typedef T2 T2Type; - typedef T3 T3Type; - - /** Constructs the object - * @param name name of he object - * @param in_param1 parameter 1 - * @param in_param2 parameter 2 - * @param in_param3 parameter 3 - */ - Invocation3( const String &name, - const T1 &in_param1, - const T2 &in_param2, - const T3 &in_param3) - : Invocation( name ) - , param1( in_param1 ) - , param2( in_param2 ) - , param3( in_param3 ) - { - } - -#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 Invocation3<T1, T2, T3> &other ) const - { - return invocationComparison(param1, other.param1) - && invocationComparison(param2, other.param2) - && invocationComparison(param3, other.param3); - } - - /** 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 - */ - const T1 & getParameter1() const - { - return param1; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T2 & getParameter2() const - { - return param2; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T3 & getParameter3() const - { - return param3; - } - - /** Returns a description of the parameters - * @return the description - */ - virtual String describeParameters() const - { - String fmt = MOCKPP_PCHAR("%1, %2, %3"); - fmt << param1 << param2 << param3; - return fmt; - } - - private: - - const T1 & param1; - const T2 & param2; - const T3 & param3; -}; - - -///////////////////////////////////////////////////////////////////// - - -/** Hold invocations with 4 parameters - * @internal - */ -template <typename T1, typename T2, typename T3, typename T4> -class Invocation4 : public Invocation -{ - public: - - enum { numParams = 4 }; - - typedef ConstraintSet4<T1, T2, T3, T4> ConstraintSetType; - typedef T1 T1Type; - typedef T2 T2Type; - typedef T3 T3Type; - typedef T4 T4Type; - - /** 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 - */ - Invocation4( const String &name, - const T1 &in_param1, - const T2 &in_param2, - const T3 &in_param3, - const T4 &in_param4) - : Invocation( name ) - , param1( in_param1 ) - , param2( in_param2 ) - , param3( in_param3 ) - , param4( in_param4 ) - { - } - -#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 Invocation4<T1, T2, T3, T4> &other ) const - { - return invocationComparison(param1, other.param1) - && invocationComparison(param2, other.param2) - && invocationComparison(param3, other.param3) - && invocationComparison(param4, other.param4); - } - - /** 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 - */ - const T1 & getParameter1() const - { - return param1; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T2 & getParameter2() const - { - return param2; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T3 & getParameter3() const - { - return param3; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T4 & getParameter4() const - { - return param4; - } - - /** Returns a description of the parameters - * @return the description - */ - virtual String describeParameters() const - { - String fmt = MOCKPP_PCHAR("%1, %2, %3, %4"); - fmt << param1 << param2 << param3 << param4; - return fmt; - } - - private: - - const T1 & param1; - const T2 & param2; - const T3 & param3; - const T4 & param4; -}; - - -///////////////////////////////////////////////////////////////////// - - -/** Hold invocations with 5 parameters - * @internal - */ -template <typename T1, typename T2, typename T3, typename T4, typename T5> -class Invocation5 : public Invocation -{ - public: - - enum { numParams = 5 }; - - typedef ConstraintSet5<T1, T2, T3, T4, T5> ConstraintSetType; - typedef T1 T1Type; - typedef T2 T2Type; - typedef T3 T3Type; - typedef T4 T4Type; - typedef T5 T5Type; - - /** 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 - */ - Invocation5( const String &name, - const T1 &in_param1, - const T2 &in_param2, - const T3 &in_param3, - const T4 &in_param4, - const T5 &in_param5) - : Invocation( name ) - , param1( in_param1 ) - , param2( in_param2 ) - , param3( in_param3 ) - , param4( in_param4 ) - , param5( in_param5 ) - { - } - -#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 Invocation5<T1, T2, T3, T4, T5> &other ) const - { - return invocationComparison(param1, other.param1) - && invocationComparison(param2, other.param2) - && invocationComparison(param3, other.param3) - && invocationComparison(param4, other.param4) - && invocationComparison(param5, other.param5); - } - - /** 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 - */ - const T1 & getParameter1() const - { - return param1; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T2 & getParameter2() const - { - return param2; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T3 & getParameter3() const - { - return param3; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T4 & getParameter4() const - { - return param4; - } - - /** Returns an invocation parameter - * @return the invocation parameter - */ - const T5 & getParameter5() const - { - return param5; - } - - /** Returns a description of the parameters - * @return the description - */ - virtual String describeParameters() const - { - String fmt = MOCKPP_PCHAR("%1, %2, %3, %4, %5"); - fmt << param1 << param2 << param3 << param4 << param5; - return fmt; - } - - private: - - const T1 & param1; - const T2 & param2; - const T3 & param3; - const T4 & param4; - const T5 & param5; -}; - - } // namespace mockpp #endif // MOCKPP_INVOKATION_H +#include "InvocationN.h" + --- NEW FILE: InvocationN.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_invocation_N.pl. $Id: InvocationN.h,v 1.1 2005/10/27 18:54:01 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Aug 24 2004 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_INVOCATION_N_H #define MOCKPP_INVOCATION_N_H //#include <mockpp/chaining/Invocation.h> namespace mockpp { /** Hold invocations with 1 parameters * @internal */ template <typename P1> class Invocation1 : public Invocation { public: enum { numParams = 1 }; typedef ConstraintSet1<P1> ConstraintSetType; typedef P1 T1Type; /** Constructs the object * @param name name of he object * @param in_param1 parameter 1 */ Invocation1( const String &name , const P1 &in_param1) : Invocation( name ) , param1( in_param1 ) { } #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 Invocation1<P1> &other ) const { return invocationComparison(param1, other.param1); } /** 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 a description of the parameters * @return the description */ virtual String describeParameters() const { String fmt = MOCKPP_PCHAR("%1"); fmt << param1; return fmt; } private: const P1 & param1; }; /** Hold invocations with 2 parameters * @internal */ template <typename P1, typename P2> class Invocation2 : public Invocation { public: enum { numParams = 2 }; typedef ConstraintSet2<P1, P2> ConstraintSetType; typedef P1 T1Type; typedef P2 T2Type; /** Constructs the object * @param name name of he object * @param in_param1 parameter 1 * @param in_param2 parameter 2 */ Invocation2( const String &name , const P1 &in_param1 , const P2 &in_param2) : Invocation( name ) , param1( in_param1 ) , param2( in_param2 ) { } #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 Invocation2<P1, P2> &other ) const { return invocationComparison(param1, other.param1) && invocationComparison(param2, other.param2); } /** 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 a description of the parameters * @return the description */ virtual String describeParameters() const { String fmt = MOCKPP_PCHAR("%1, %2"); fmt << param1 << param2; return fmt; } private: const P1 & param1; const P2 & param2; }; /** Hold invocations with 3 parameters * @internal */ template <typename P1, typename P2, typename P3> class Invocation3 : public Invocation { public: enum { numParams = 3 }; typedef ConstraintSet3<P1, P2, P3> ConstraintSetType; typedef P1 T1Type; typedef P2 T2Type; typedef P3 T3Type; /** Constructs the object * @param name name of he object * @param in_param1 parameter 1 * @param in_param2 parameter 2 * @param in_param3 parameter 3 */ Invocation3( const String &name , const P1 &in_param1 , const P2 &in_param2 , const P3 &in_param3) : Invocation( name ) , param1( in_param1 ) , param2( in_param2 ) , param3( in_param3 ) { } #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 Invocation3<P1, P2, P3> &other ) const { return invocationComparison(param1, other.param1) && invocationComparison(param2, other.param2) && invocationComparison(param3, other.param3); } /** 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 a description of the parameters * @return the description */ virtual String describeParameters() const { String fmt = MOCKPP_PCHAR("%1, %2, %3"); fmt << param1 << param2 << param3; return fmt; } private: const P1 & param1; const P2 & param2; const P3 & param3; }; /** Hold invocations with 4 parameters * @internal */ template <typename P1, typename P2, typename P3, typename P4> class Invocation4 : public Invocation { public: enum { numParams = 4 }; typedef ConstraintSet4<P1, P2, P3, P4> ConstraintSetType; typedef P1 T1Type; typedef P2 T2Type; typedef P3 T3Type; typedef P4 T4Type; /** 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 */ Invocation4( const String &name , const P1 &in_param1 , const P2 &in_param2 , const P3 &in_param3 , const P4 &in_param4) : Invocation( name ) , param1( in_param1 ) , param2( in_param2 ) , param3( in_param3 ) , param4( in_param4 ) { } #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 Invocation4<P1, P2, P3, P4> &other ) const { return invocationComparison(param1, other.param1) && invocationComparison(param2, other.param2) && invocationComparison(param3, other.param3) && invocationComparison(param4, other.param4); } /** 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 a description of the parameters * @return the description */ virtual String describeParameters() const { String fmt = MOCKPP_PCHAR("%1, %2, %3, %4"); fmt << param1 << param2 << param3 << param4; return fmt; } private: const P1 & param1; const P2 & param2; const P3 & param3; const P4 & param4; }; /** Hold invocations with 5 parameters * @internal */ template <typename P1, typename P2, typename P3, typename P4, typename P5> class Invocation5 : public Invocation { public: enum { numParams = 5 }; typedef ConstraintSet5<P1, P2, P3, P4, P5> ConstraintSetType; typedef P1 T1Type; typedef P2 T2Type; typedef P3 T3Type; typedef P4 T4Type; typedef P5 T5Type; /** 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 */ Invocation5( const String &name , const P1 &in_param1 , const P2 &in_param2 , const P3 &in_param3 , const P4 &in_param4 , const P5 &in_param5) : Invocation( name ) , param1( in_param1 ) , param2( in_param2 ) , param3( in_param3 ) , param4( in_param4 ) , param5( in_param5 ) { } #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 Invocation5<P1, P2, P3, P4, P5> &other ) const { return invocationComparison(param1, other.param1) && invocationComparison(param2, other.param2) && invocationComparison(param3, other.param3) && invocationComparison(param4, other.param4) && invocationComparison(param5, other.param5); } /** 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 a description of the parameters * @return the description */ virtual String describeParameters() const { String fmt = MOCKPP_PCHAR("%1, %2, %3, %4, %5"); fmt << param1 << param2 << param3 << param4 << param5; return fmt; } private: const P1 & param1; const P2 & param2; const P3 & param3; const P4 & param4; const P5 & param5; }; } // ns mockpp #endif // MOCKPP_INVOCATION_N_H |
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27372/mockpp Modified Files: Makefile.am VisitableMockObject_template.h Added Files: ResponseVector1.h ResponseVector2.h ResponseVector3.h ResponseVector4.h ResponseVector5.h Log Message: basic file set working --- NEW FILE: ResponseVector3.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector3.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 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_ResponseVector3_H #define MOCKPP_ResponseVector3_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1, typename P2, typename P3> class ResponseThrowableVector3 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector3(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector3() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2); const ConstraintHolder<P3> h3 = new IsEqual<P3>(p3); add(t, h1, h2, h3, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); typename mockpp::Constraint<P2>::AP cons2 (p2); typename mockpp::Constraint<P3>::AP cons3 (p3); t1vec.push_back(cons1.release()); t2vec.push_back(cons2.release()); t3vec.push_back(cons3.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); for (unsigned i2 = 0; i2 < t2vec.size(); ++i2) delete t2vec[i2]; t2vec.clear(); for (unsigned i3 = 0; i3 < t3vec.size(); ++i3) delete t3vec[i3]; t3vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) && t2vec[i]->eval(p2) && t3vec[i]->eval(p3) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; std::vector<Constraint<P2>*> t2vec; std::vector<Constraint<P3>*> t3vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1, typename P2, typename P3> class ResponseVector3 : public ResponseThrowableVector3<P1, P2, P3> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector3(const String &aName, VerifiableList *parent) : ResponseThrowableVector3<P1, P2, P3>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector3<P1, P2, P3>::add(t, p1, p2, p3, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector3<P1, P2, P3>::add (t, p1, p2, p3, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count) { ResponseThrowableVector3<P1, P2, P3>::add((Throwable*)0, p1, p2, p3, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count) { ResponseThrowableVector3<P1, P2, P3>::add((Throwable*)0, p1, p2, p3, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector3<P1, P2, P3>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3) { return ResponseThrowableVector3<P1, P2, P3>::find(t, p1, p2, p3); } #else using ResponseThrowableVector3<P1, P2, P3>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1, const P2 &p2, const P3 &p3) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) && this->t2vec[i]->eval(p2) && this->t3vec[i]->eval(p3) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector3_H --- NEW FILE: ResponseVector4.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector4.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 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_ResponseVector4_H #define MOCKPP_ResponseVector4_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1, typename P2, typename P3, typename P4> class ResponseThrowableVector4 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector4(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector4() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2); const ConstraintHolder<P3> h3 = new IsEqual<P3>(p3); const ConstraintHolder<P4> h4 = new IsEqual<P4>(p4); add(t, h1, h2, h3, h4, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); typename mockpp::Constraint<P2>::AP cons2 (p2); typename mockpp::Constraint<P3>::AP cons3 (p3); typename mockpp::Constraint<P4>::AP cons4 (p4); t1vec.push_back(cons1.release()); t2vec.push_back(cons2.release()); t3vec.push_back(cons3.release()); t4vec.push_back(cons4.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); for (unsigned i2 = 0; i2 < t2vec.size(); ++i2) delete t2vec[i2]; t2vec.clear(); for (unsigned i3 = 0; i3 < t3vec.size(); ++i3) delete t3vec[i3]; t3vec.clear(); for (unsigned i4 = 0; i4 < t4vec.size(); ++i4) delete t4vec[i4]; t4vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) && t2vec[i]->eval(p2) && t3vec[i]->eval(p3) && t4vec[i]->eval(p4) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; std::vector<Constraint<P2>*> t2vec; std::vector<Constraint<P3>*> t3vec; std::vector<Constraint<P4>*> t4vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1, typename P2, typename P3, typename P4> class ResponseVector4 : public ResponseThrowableVector4<P1, P2, P3, P4> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector4(const String &aName, VerifiableList *parent) : ResponseThrowableVector4<P1, P2, P3, P4>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector4<P1, P2, P3, P4>::add(t, p1, p2, p3, p4, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector4<P1, P2, P3, P4>::add (t, p1, p2, p3, p4, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count) { ResponseThrowableVector4<P1, P2, P3, P4>::add((Throwable*)0, p1, p2, p3, p4, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count) { ResponseThrowableVector4<P1, P2, P3, P4>::add((Throwable*)0, p1, p2, p3, p4, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector4<P1, P2, P3, P4>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) { return ResponseThrowableVector4<P1, P2, P3, P4>::find(t, p1, p2, p3, p4); } #else using ResponseThrowableVector4<P1, P2, P3, P4>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) && this->t2vec[i]->eval(p2) && this->t3vec[i]->eval(p3) && this->t4vec[i]->eval(p4) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector4_H --- NEW FILE: ResponseVector2.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector2.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 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_ResponseVector2_H #define MOCKPP_ResponseVector2_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1, typename P2> class ResponseThrowableVector2 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector2(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector2() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2); add(t, h1, h2, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); typename mockpp::Constraint<P2>::AP cons2 (p2); t1vec.push_back(cons1.release()); t2vec.push_back(cons2.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); for (unsigned i2 = 0; i2 < t2vec.size(); ++i2) delete t2vec[i2]; t2vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1, const P2 &p2) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) && t2vec[i]->eval(p2) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; std::vector<Constraint<P2>*> t2vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1, typename P2> class ResponseVector2 : public ResponseThrowableVector2<P1, P2> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector2(const String &aName, VerifiableList *parent) : ResponseThrowableVector2<P1, P2>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector2<P1, P2>::add(t, p1, p2, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector2<P1, P2>::add (t, p1, p2, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, const P2 &p2, unsigned count) { ResponseThrowableVector2<P1, P2>::add((Throwable*)0, p1, p2, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count) { ResponseThrowableVector2<P1, P2>::add((Throwable*)0, p1, p2, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector2<P1, P2>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1, const P2 &p2) { return ResponseThrowableVector2<P1, P2>::find(t, p1, p2); } #else using ResponseThrowableVector2<P1, P2>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1, const P2 &p2) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) && this->t2vec[i]->eval(p2) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector2_H Index: VisitableMockObject_template.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/VisitableMockObject_template.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- VisitableMockObject_template.h 31 Jul 2005 14:22:57 -0000 1.26 +++ VisitableMockObject_template.h 26 Oct 2005 20:43:31 -0000 1.27 @@ -34,6 +34,7 @@ #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> + namespace mockpp { @@ -92,1288 +93,17 @@ std::vector<unsigned> counter; }; [...1273 lines suppressed...] - - private: - - std::vector<R> rvec; -}; - #endif // DOXYGEN_SHOULD_SKIP_THIS } // namespace mockpp +#include "ResponseVector1.h" +#include "ResponseVector2.h" +#include "ResponseVector3.h" +#include "ResponseVector4.h" +#include "ResponseVector5.h" + + #endif // MOCKPP_VISITABLEMOCKOBJECT_TEMPLATE_H + --- NEW FILE: ResponseVector1.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector1.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 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_ResponseVector1_H #define MOCKPP_ResponseVector1_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1> class ResponseThrowableVector1 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector1(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector1() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); add(t, h1, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); t1vec.push_back(cons1.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1> class ResponseVector1 : public ResponseThrowableVector1<P1> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector1(const String &aName, VerifiableList *parent) : ResponseThrowableVector1<P1>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector1<P1>::add(t, p1, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector1<P1>::add (t, p1, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, unsigned count) { ResponseThrowableVector1<P1>::add((Throwable*)0, p1, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, unsigned count) { ResponseThrowableVector1<P1>::add((Throwable*)0, p1, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector1<P1>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1) { return ResponseThrowableVector1<P1>::find(t, p1); } #else using ResponseThrowableVector1<P1>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector1_H Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/Makefile.am,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- Makefile.am 24 Oct 2005 19:08:44 -0000 1.90 +++ Makefile.am 26 Oct 2005 20:43:31 -0000 1.91 @@ -37,7 +37,12 @@ VisitableMockMethod2.h \ VisitableMockMethod3.h \ VisitableMockMethod4.h \ - VisitableMockMethod5.h + VisitableMockMethod5.h \ + ResponseVector1.h \ + ResponseVector2.h \ + ResponseVector3.h \ + ResponseVector4.h \ + ResponseVector5.h EXTRA_DIST = \ mockpp_config-bcb5.h \ @@ -47,7 +52,8 @@ visitable-template.raw \ chainable-template.h \ chainable-template.raw \ - gen_visitablemethod_N.pl + gen_visitablemethod_N.pl \ + gen_responsevector_N.pl CLEANFILES = *.~* *.~~* *~ mockpp_config.h *.old --- NEW FILE: ResponseVector5.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector5.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 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_ResponseVector5_H #define MOCKPP_ResponseVector5_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1, typename P2, typename P3, typename P4, typename P5> class ResponseThrowableVector5 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector5(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector5() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2); const ConstraintHolder<P3> h3 = new IsEqual<P3>(p3); const ConstraintHolder<P4> h4 = new IsEqual<P4>(p4); const ConstraintHolder<P5> h5 = new IsEqual<P5>(p5); add(t, h1, h2, h3, h4, h5, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); typename mockpp::Constraint<P2>::AP cons2 (p2); typename mockpp::Constraint<P3>::AP cons3 (p3); typename mockpp::Constraint<P4>::AP cons4 (p4); typename mockpp::Constraint<P5>::AP cons5 (p5); t1vec.push_back(cons1.release()); t2vec.push_back(cons2.release()); t3vec.push_back(cons3.release()); t4vec.push_back(cons4.release()); t5vec.push_back(cons5.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); for (unsigned i2 = 0; i2 < t2vec.size(); ++i2) delete t2vec[i2]; t2vec.clear(); for (unsigned i3 = 0; i3 < t3vec.size(); ++i3) delete t3vec[i3]; t3vec.clear(); for (unsigned i4 = 0; i4 < t4vec.size(); ++i4) delete t4vec[i4]; t4vec.clear(); for (unsigned i5 = 0; i5 < t5vec.size(); ++i5) delete t5vec[i5]; t5vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) && t2vec[i]->eval(p2) && t3vec[i]->eval(p3) && t4vec[i]->eval(p4) && t5vec[i]->eval(p5) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; std::vector<Constraint<P2>*> t2vec; std::vector<Constraint<P3>*> t3vec; std::vector<Constraint<P4>*> t4vec; std::vector<Constraint<P5>*> t5vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class ResponseVector5 : public ResponseThrowableVector5<P1, P2, P3, P4, P5> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector5(const String &aName, VerifiableList *parent) : ResponseThrowableVector5<P1, P2, P3, P4, P5>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector5<P1, P2, P3, P4, P5>::add(t, p1, p2, p3, p4, p5, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector5<P1, P2, P3, P4, P5>::add (t, p1, p2, p3, p4, p5, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count) { ResponseThrowableVector5<P1, P2, P3, P4, P5>::add((Throwable*)0, p1, p2, p3, p4, p5, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count) { ResponseThrowableVector5<P1, P2, P3, P4, P5>::add((Throwable*)0, p1, p2, p3, p4, p5, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector5<P1, P2, P3, P4, P5>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) { return ResponseThrowableVector5<P1, P2, P3, P4, P5>::find(t, p1, p2, p3, p4, p5); } #else using ResponseThrowableVector5<P1, P2, P3, P4, P5>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) && this->t2vec[i]->eval(p2) && this->t3vec[i]->eval(p3) && this->t4vec[i]->eval(p4) && this->t5vec[i]->eval(p5) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector5_H |
From: Ewald A. <ewa...@us...> - 2005-10-26 20:05:54
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16443/mockpp Modified Files: gen_visitablemethod_N.pl Log Message: typo Index: gen_visitablemethod_N.pl =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/gen_visitablemethod_N.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gen_visitablemethod_N.pl 25 Oct 2005 19:05:29 -0000 1.4 +++ gen_visitablemethod_N.pl 26 Oct 2005 20:05:43 -0000 1.5 @@ -305,7 +305,7 @@ typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. - * \@meth poiinter to according method mock. + * \@meth pointer to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) @@ -434,7 +434,7 @@ typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. - * \@meth poiinter to according method mock. + * \@meth pointer to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) @@ -539,7 +539,7 @@ typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. - * \@meth poiinter to according method mock. + * \@meth pointer to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) |
From: Ewald A. <ewa...@us...> - 2005-10-26 20:05:16
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16303/mockpp Added Files: gen_responsevector_N.pl Log Message: new --- NEW FILE: gen_responsevector_N.pl --- #!/usr/bin/perl -w # # $Id: gen_responsevector_N.pl,v 1.1 2005/10/26 20:05:07 ewald-arnold Exp $ use English; if ($#ARGV < 0) { print "Usage: perl gen_responsevector_N <number of arguments>\n"; exit; } $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } for ($numArgs = 1; $numArgs <= $totalNumArgs; ++$numArgs) { open OUT, ">ResponseVector" . $numArgs . ".h"; print "Creating ResponseVector" . $numArgs . ".h\n"; print OUT "/** \@file \@internal NOT INTENDED FOR PUBLIC INCLUSION \@brief Generated with gen_responsevector_N.pl. \$I" . "d: ResponseVector" . $numArgs . ".h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 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_ResponseVector" . $numArgs . "_H #define MOCKPP_ResponseVector" . $numArgs . "_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { "; $templateParms = ""; $templateParms_colon = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $templateParms .= ", "; } $templateParms .= "typename P$i"; } if ($numArgs > 0) { $templateParms_colon = ", " . $templateParms; } $templateArgs_colon = ""; $_ = $templateParms; s/typename //g; $templateArgs = $_; if ($numArgs > 0) { $templateArgs_colon = ", ". $templateArgs; } $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $parms .= ", "; } $parms .= "const P$i &p$i"; } $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $holderParms .= ", "; } $holderParms .= "const ConstraintHolder<P$i> &p$i"; } $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $args .= ", "; } $args .= "p$i"; } $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $boundArgs .= ", "; } $boundArgs .= "args->a$i"; } $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $copyParms .= ", "; } $copyParms .= "P$i ia$i"; } $hArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $hArgs .= ", "; } $hArgs .= "h$i"; } $initArgs = ""; if ($numArgs > 0) { $initArgs = ":"; } for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $initArgs .= ", "; } $initArgs .= "p$i(ip$i)"; } $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argTypes .= "typedef P$i p". ($i+1) . "_type; "; } print OUT " /** Class returning a throwable depending on the parameters * passed to a method. */ template <" . $templateParms . "> class ResponseThrowableVector" . $numArgs . " : public ResponseVectorBase { public: /** * Construct a new empty vector * \@param aName Label used to identify vector * \@param parent parent verifiable */ ResponseThrowableVector" . $numArgs . "(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector" . $numArgs . "() { reset(); } /** Adds a throwable. * \@param t the throwable"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " the parameter " . $p . " upon which to return"; } print OUT " * \@param count the number of times the object may be used */ void add(Throwable *t, " . $parms . ", unsigned count) {"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " const ConstraintHolder<P" . $p . "> p" . $p . " = new IsEqual<P" . $p . ">(p" . $p . ");" } print OUT " add(t, " . $args . ", count); } /** Adds a throwable. * \@param t the throwable"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " the parameter " . $p . " upon which to return"; } print OUT " * \@param count the number of times the object may be used */ void add(Throwable *t,"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " const ConstraintHolder<P" . $p . "> &p" . $p . ","; } print OUT " unsigned count) { counter.push_back(count); tvec.push_back(t);"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " typename mockpp::Constraint<P" . $p . ">::AP cons" . $p . " (p" . $p . ");"; } for($p = 1; $p <= $numArgs; ++$p) { print OUT " p" . $p . "vec.push_back(cons" . $p . ".release());"; } print OUT " } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear();"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " for (unsigned i" . $p . " = 0; i" . $p . " < t" . $p . "vec.size(); ++i" . $p . ") delete t" . $p . "vec[i" . $p . "]; t" . $p . "vec.clear();"; } print OUT " } /** Finds a throwable for a set of parameters. * \@param t the throwable"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " the parameter " . $p . " upon which to return"; } print OUT " * \@return true: throwable found for parameters */ bool find(Throwable * &t, " . $parms . ") { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " && t" . $p . "vec[i]->eval(p" . $p . ")"; } print OUT " { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: "; for($p = 1; $p <= $numArgs; ++$p) { print OUT " std::vector<Constraint<P" . $p . ">*> t" . $p . "vec;"; } print OUT " }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <" . $templateParms . "> class ResponseVector" . $numArgs . " : public ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> { public: /** Construct a new empty vector * \@param aName Label used to identify vector * \@param parent parent verifiable */ ResponseVector" . $numArgs . "(const String &aName, VerifiableList *parent) : ResponseThrowableVector" . $numArgs . "<" . $templateArgs . ">(aName, parent) {} /** Adds a throwable. * \@param t the throwable"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " the parameter " . $p . " upon which to return"; } print OUT " * \@param count the number of times the object may be used */ void add(Throwable *t, " . $parms . ", unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector" . $numArgs . "<" . $templateArgs . ">::add(t, " . $args . ", count); R r; rvec.push_back(r); } /** Adds a throwable. * \@param t the throwable"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " the parameter " . $p . " upon which to return"; } print OUT " * \@param count the number of times the object may be used */ void add(Throwable *t,"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " const ConstraintHolder<P" . $p . "> &p" . $p . ",";} print OUT " unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector" . $numArgs . "<" . $templateArgs . ">::add (t, " . $args . ", count); R r; rvec.push_back(r); } /** Adds a return value. * \@param r the return value"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " the parameter " . $p . " upon which to return"; } print OUT " * \@param count the number of times the object may be used */ void add(const R &r, " . $parms . ", unsigned count) { ResponseThrowableVector" . $numArgs . "<" . $templateArgs . ">::add((Throwable*)0, " . $args . ", count); rvec.push_back(r); } /** Adds a return value. * \@param r the return value"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " the parameter " . $p . " upon which to return"; } print OUT " * \@param count the number of times the object may be used */ void add(const R &r,"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " const ConstraintHolder<P" . $p . "> &p" . $p . ","; } print OUT " unsigned count) { ResponseThrowableVector" . $numArgs . "<" . $templateArgs . ">::add((Throwable*)0, " . $args . ", count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector" . $numArgs . "<" . $templateArgs . ">::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, " . $parms . ") { return ResponseThrowableVector" . $numArgs . "<" . $templateArgs . ">::find(t, " . $args . "); } #else using ResponseThrowableVector" . $numArgs . "<" . $templateArgs . ">::find; #endif /** Finds a return value for a set of parameters. * \@param r the value"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " the parameter " . $p . " upon which to return"; } print OUT " * \@return true: return value found for parameters */ bool find(R &r, " . $parms . ") { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " && this->t" . $p . "vec[i]->eval(p" . $p . ")"; } print OUT " { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector" . $numArgs . "_H "; close OUT; } |
From: Ewald A. <ewa...@us...> - 2005-10-26 20:04:45
|
Update of /cvsroot/mockpp/mockpp/mockpp/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16162/mockpp/tests Modified Files: ArgumentsMatchBuilder_test.cpp Log Message: superfluous template Index: ArgumentsMatchBuilder_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/ArgumentsMatchBuilder_test.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- ArgumentsMatchBuilder_test.cpp 15 Oct 2005 15:40:58 -0000 1.24 +++ ArgumentsMatchBuilder_test.cpp 26 Oct 2005 20:04:29 -0000 1.25 @@ -191,7 +191,10 @@ c0.withNoArguments(); } //---------------------------------------- - { + +#if 0 + +{ Container0<mockpp::ArgumentsMatchBuilderX<void, Void0Invocation> > cxv; cxv.withAnyArguments(); @@ -213,7 +216,10 @@ Container0<mockpp::ArgumentsMatchBuilderX<int, Getter5Invocation> > cx5; cx5.withAnyArguments(); } -//---------------------------------------- + +#endif + + //---------------------------------------- { CA ca; CB cb; @@ -221,6 +227,8 @@ CD cd; CE ce; +#if 0 + ContainerX<mockpp::ArgumentsMatchBuilderX<int, Getter0Invocation> > cx; cx.withAnyArguments(); MOCKPP_ASSERT_TRUE( cx.last_matcher->toString() == MOCKPP_PCHAR("(any arguments)") ); @@ -228,6 +236,8 @@ ContainerX<mockpp::ArgumentsMatchBuilder0<int, Getter0Invocation> > c0; c0.withNoArguments(); MOCKPP_ASSERT_TRUE( c0.last_matcher->toString() == MOCKPP_PCHAR("(no arguments)") ); + +#endif ContainerX<mockpp::ArgumentsMatchBuilder1<int, Getter1Invocation> > c1; c1.with(new mockpp::IsEqual<CA>(ca)); |
From: Ewald A. <ewa...@us...> - 2005-10-26 20:04:45
|
Update of /cvsroot/mockpp/mockpp/mockpp/builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16162/mockpp/builder Modified Files: ArgumentsMatchBuilder.h Log Message: superfluous template Index: ArgumentsMatchBuilder.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/builder/ArgumentsMatchBuilder.h,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- ArgumentsMatchBuilder.h 3 Mar 2005 15:57:18 -0000 1.28 +++ ArgumentsMatchBuilder.h 26 Oct 2005 20:04:29 -0000 1.29 @@ -89,45 +89,6 @@ }; -/** Build a matcher for an invocation with any argument count. - * @ingroup grp_chainer - * @internal - */ -template <typename R, // Returntype - typename I> // Invocation -class ArgumentsMatchBuilderX : public MatchBuilder<R,I> -{ - public: - - typedef R ReturnType; - typedef I InvocationType; - typedef ConstraintSet0 ConstraintSetType; - - /** Indicate a matcher for \c any arguments. - * @ingroup grp_chainer - * @return the builder object - */ - MatchBuilder<R, I>& with() - { - return addMatcher( new AnyArgumentsMatcher<I>() ); - } - - /** Adds another matcher. - * @param matcher the matcher object - * @return the builder object - */ - virtual MatchBuilder<R, I>& addMatcher( const MatcherHolder<I> &matcher ) = 0; - - /** Indicate a matcher for \c any arguments. - * @return the builder object - */ - MatchBuilder<R, I>& withAnyArguments() - { - return addMatcher( new AnyArgumentsMatcher<I>() ); - } -}; - - /** Build a matcher for an invocation with 1 argument. * @ingroup grp_chainer * @internal |
From: Ewald A. <ewa...@us...> - 2005-10-25 20:20:33
|
Update of /cvsroot/mockpp/mockpp/mockpp/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15806/mockpp/tests Modified Files: ChainableMockMethod_1_test.cpp ChainableMockMethod_2_test.cpp ChainableMockMethod_test.cpp Log Message: basic file set working Index: ChainableMockMethod_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/ChainableMockMethod_test.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ChainableMockMethod_test.cpp 18 Oct 2005 20:03:53 -0000 1.5 +++ ChainableMockMethod_test.cpp 25 Oct 2005 20:20:18 -0000 1.6 @@ -38,6 +38,12 @@ #else #include <mockpp/chaining/ChainableMockMethod.h> +#include <mockpp/chaining/ChainableMockMethod0.h> +#include <mockpp/chaining/ChainableMockMethod1.h> +#include <mockpp/chaining/ChainableMockMethod2.h> +#include <mockpp/chaining/ChainableMockMethod3.h> +#include <mockpp/chaining/ChainableMockMethod4.h> +#include <mockpp/chaining/ChainableMockMethod5.h> #include <mockpp/chaining/ChainingMockObjectSupport.h> #include <mockpp/chaining/Invocation.h> Index: ChainableMockMethod_1_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/ChainableMockMethod_1_test.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ChainableMockMethod_1_test.cpp 18 Oct 2005 20:17:16 -0000 1.7 +++ ChainableMockMethod_1_test.cpp 25 Oct 2005 20:20:18 -0000 1.8 @@ -38,6 +38,12 @@ #else #include <mockpp/chaining/ChainableMockMethod.h> +#include <mockpp/chaining/ChainableMockMethod0.h> +#include <mockpp/chaining/ChainableMockMethod1.h> +#include <mockpp/chaining/ChainableMockMethod2.h> +#include <mockpp/chaining/ChainableMockMethod3.h> +#include <mockpp/chaining/ChainableMockMethod4.h> +#include <mockpp/chaining/ChainableMockMethod5.h> #include <mockpp/chaining/ChainingMockObjectSupport.h> #include <mockpp/chaining/Invocation.h> Index: ChainableMockMethod_2_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/ChainableMockMethod_2_test.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- ChainableMockMethod_2_test.cpp 18 Oct 2005 20:03:53 -0000 1.5 +++ ChainableMockMethod_2_test.cpp 25 Oct 2005 20:20:18 -0000 1.6 @@ -38,6 +38,12 @@ #else #include <mockpp/chaining/ChainableMockMethod.h> +#include <mockpp/chaining/ChainableMockMethod0.h> +#include <mockpp/chaining/ChainableMockMethod1.h> +#include <mockpp/chaining/ChainableMockMethod2.h> +#include <mockpp/chaining/ChainableMockMethod3.h> +#include <mockpp/chaining/ChainableMockMethod4.h> +#include <mockpp/chaining/ChainableMockMethod5.h> #include <mockpp/chaining/ChainingMockObjectSupport.h> #include <mockpp/chaining/Invocation.h> |
From: Ewald A. <ewa...@us...> - 2005-10-25 20:19:47
|
Update of /cvsroot/mockpp/mockpp/mockpp/chaining In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15599/mockpp/chaining Modified Files: ChainableMockMethod.h Makefile.am Added Files: ChainableMockMethod0.h ChainableMockMethod1.h ChainableMockMethod2.h ChainableMockMethod3.h ChainableMockMethod4.h ChainableMockMethod5.h gen_chainablemethod_N.pl Log Message: basic file set working Index: ChainableMockMethod.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/chaining/ChainableMockMethod.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ChainableMockMethod.h 18 Oct 2005 19:09:24 -0000 1.6 +++ ChainableMockMethod.h 25 Oct 2005 20:19:31 -0000 1.7 @@ -40,7 +40,7 @@ template <typename R> -class ChainableMockMethodBase : public MockObject +class ChainableMockMethodCommon : public MockObject { public: @@ -48,7 +48,7 @@ * @param name human readable description about the expectation * @param parent parent chainable mock object */ - ChainableMockMethodBase(const String &name, ChainableMockObject *parent ) + ChainableMockMethodCommon(const String &name, ChainableMockObject *parent ) : MockObject(name, parent) , chainable(parent) {} @@ -70,274 +70,8 @@ }; -///////////////////////////////////////////////////////////////////////////////////////////// - - -template <typename R> -class ChainableMockMethod0Base : public ChainableMockMethodBase<R> -{ - public: - - typedef R ReturnType; - typedef Invocation0 InvocationType; - typedef CoreMock<R, InvocationType> CoreMockType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod0Base(const String &name, ChainableMockObject *parent ) - : ChainableMockMethodBase<R>(name, parent) - , coremock(name + MOCKPP_PCHAR("/coreMock"), this) - {} - - CoreMockType & getCoreMock() const - { - return coremock; - } - - typedef ChainingMockBuilder <ArgumentsMatchBuilder0<ReturnType, InvocationType> > Builder; - - class ChainerFor : public Builder - { - public: - - ChainerFor(ChainableMockMethod0Base &method) - : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) - {} - }; - - private: - - mutable CoreMockType coremock; -}; - - -template <typename R> -class ChainableMockMethod0 : public ChainableMockMethod0Base<R> -{ - public: - - typedef typename ChainableMockMethod0Base<R>::InvocationType InvocationType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod0(const String &name, ChainableMockObject *parent ) - : ChainableMockMethod0Base<R>(name, parent) - {} - - R forward() const - { - InvocationType inv(this->getMethodName()); - return this->getCoreMock().invoke(inv); - } -}; - - -template <> -class ChainableMockMethod0<void> : public ChainableMockMethod0Base<void> -{ - public: - - typedef ChainableMockMethod0Base<void>::InvocationType InvocationType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod0(const String &name, ChainableMockObject *parent) - : ChainableMockMethod0Base<void>(name, parent) - {} - - void forward() const - { - InvocationType inv(MOCKPP_PCHAR("void-name")); - this->getCoreMock().invoke(inv); - } -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// - - -template <typename R, typename P1> -class ChainableMockMethod1Base : public ChainableMockMethodBase<R> -{ - public: - - typedef R ReturnType; - typedef Invocation1<P1> InvocationType; - typedef CoreMock<R, InvocationType> CoreMockType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod1Base(const String &name, ChainableMockObject *parent ) - : ChainableMockMethodBase<R>(name, parent) - , coremock(name + MOCKPP_PCHAR("/coreMock"), this) - {} - - CoreMockType & getCoreMock() const - { - return coremock; - } - - typedef ChainingMockBuilder <ArgumentsMatchBuilder1<ReturnType, InvocationType> > Builder; - - class ChainerFor : public Builder - { - public: - - ChainerFor(ChainableMockMethod1Base &method) - : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) - {} - }; - - private: - - mutable CoreMockType coremock; -}; - - -template <typename R, typename P1> -class ChainableMockMethod1 : public ChainableMockMethod1Base<R, P1> -{ - public: - - typedef typename ChainableMockMethod1Base<R, P1>::InvocationType InvocationType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod1(const String &name, ChainableMockObject *parent ) - : ChainableMockMethod1Base<R, P1>(name, parent) - {} - - R forward(const P1 ¶m1) const - { - InvocationType inv(this->getMethodName(), param1); - return this->getCoreMock().invoke(inv); - } -}; - - -template <typename P1> -class ChainableMockMethod1<void, P1> : public ChainableMockMethod1Base<void, P1> -{ - public: - - typedef typename ChainableMockMethod1Base<void, P1>::InvocationType InvocationType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod1(const String &name, ChainableMockObject *parent ) - : ChainableMockMethod1Base<void, P1>(name, parent) - {} - - void forward(const P1 ¶m1) const - { - InvocationType inv(MOCKPP_PCHAR("void-name"), param1); - this->getCoreMock().invoke(inv); - } -}; - - -///////////////////////////////////////////////////////////////////////////////////////////// - - -template <typename R, typename P1, typename P2> -class ChainableMockMethod2Base : public ChainableMockMethodBase<R> -{ - public: - - typedef R ReturnType; - typedef Invocation2<P1, P2> InvocationType; - typedef CoreMock<R, InvocationType> CoreMockType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod2Base(const String &name, ChainableMockObject *parent ) - : ChainableMockMethodBase<R>(name, parent) - , coremock(name + MOCKPP_PCHAR("/coreMock"), this) - {} - - CoreMockType & getCoreMock() const - { - return coremock; - } - - typedef ChainingMockBuilder <ArgumentsMatchBuilder2<ReturnType, InvocationType> > Builder; - - class ChainerFor : public Builder - { - public: - - ChainerFor(ChainableMockMethod2Base &method) - : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) - {} - }; - - private: - - mutable CoreMockType coremock; -}; - - -template <typename R, typename P1, typename P2> -class ChainableMockMethod2 : public ChainableMockMethod2Base<R, P1, P2> -{ - public: - - typedef typename ChainableMockMethod2Base<void, P1, P2>::InvocationType InvocationType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod2(const String &name, ChainableMockObject *parent ) - : ChainableMockMethod2Base<R, P1, P2>(name, parent) - {} - - R forward(const P1 ¶m1, const P2 ¶m2) const - { - InvocationType inv(this->getMethodName(), param1, param2); - return this->getCoreMock().invoke(inv); - } -}; - - -template <typename P1, typename P2> -class ChainableMockMethod2<void, P1, P2> : public ChainableMockMethod2Base<void, P1, P2> -{ - public: - - typedef typename ChainableMockMethod2Base<void, P1, P2>::InvocationType InvocationType; - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent chainable mock object - */ - ChainableMockMethod2(const String &name, ChainableMockObject *parent ) - : ChainableMockMethod2Base<void, P1, P2>(name, parent) - {} - - void forward(const P1 ¶m1, const P2 ¶m2) const - { - InvocationType inv(this->getMethodName(), param1, param2); - this->getCoreMock().invoke(inv); - } -}; - - } // namespace mockpp #endif // MOCKPP_CHAINABLEMOCKMETHOD_H + --- NEW FILE: ChainableMockMethod2.h --- /** @file @brief Chainable Mock Method with 2 parameters. Generated with gen_chainablemethod_N.pl. $Id: ChainableMockMethod2.h,v 1.1 2005/10/25 20:19:31 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_ChainableMockMethod2_H #define MOCKPP_ChainableMockMethod2_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 2 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2> class ChainableMockMethod2Common : public ChainableMockMethodCommon<R> { public: typedef Invocation2<P1, P2> 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 */ ChainableMockMethod2Common(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 <ArgumentsMatchBuilder2<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(ChainableMockMethod2Common &method) : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) { } }; private: mutable CoreMockType coremock; }; /** Set up a chainable mock method expectations with 2 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2> class ChainableMockMethod2 : public ChainableMockMethod2Common<R, P1, P2> { public: typedef typename ChainableMockMethod2Common<R, P1, P2>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod2(const String &name, ChainableMockObject *parent ) : ChainableMockMethod2Common<R, P1, P2>(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 */ R forward(const P1 &p1, const P2 &p2) const { InvocationType inv(this->getMethodName(), p1, p2); return this->getCoreMock().invoke(inv); } }; /** Set up a chainable mock method expectations with 2 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2> class ChainableMockMethod2<void, P1, P2> : public ChainableMockMethod2Common<void, P1, P2> { public: typedef typename ChainableMockMethod2Common<void, P1, P2>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod2(const String &name, ChainableMockObject *parent ) : ChainableMockMethod2Common<void, P1, P2>(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 */ void forward(const P1 &p1, const P2 &p2) const { InvocationType inv(this->getMethodName(), p1, p2); this->getCoreMock().invoke(inv); } }; } // ns mockpp #endif // MOCKPP_ChainableMockMethod2_H --- NEW FILE: ChainableMockMethod3.h --- /** @file @brief Chainable Mock Method with 3 parameters. Generated with gen_chainablemethod_N.pl. $Id: ChainableMockMethod3.h,v 1.1 2005/10/25 20:19:31 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_ChainableMockMethod3_H #define MOCKPP_ChainableMockMethod3_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 3 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3> class ChainableMockMethod3Common : public ChainableMockMethodCommon<R> { public: typedef Invocation3<P1, P2, P3> 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 */ ChainableMockMethod3Common(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 <ArgumentsMatchBuilder3<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(ChainableMockMethod3Common &method) : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) { } }; private: mutable CoreMockType coremock; }; /** Set up a chainable mock method expectations with 3 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3> class ChainableMockMethod3 : public ChainableMockMethod3Common<R, P1, P2, P3> { public: typedef typename ChainableMockMethod3Common<R, P1, P2, P3>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod3(const String &name, ChainableMockObject *parent ) : ChainableMockMethod3Common<R, P1, P2, P3>(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 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3) const { InvocationType inv(this->getMethodName(), p1, p2, p3); return this->getCoreMock().invoke(inv); } }; /** Set up a chainable mock method expectations with 3 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3> class ChainableMockMethod3<void, P1, P2, P3> : public ChainableMockMethod3Common<void, P1, P2, P3> { public: typedef typename ChainableMockMethod3Common<void, P1, P2, P3>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod3(const String &name, ChainableMockObject *parent ) : ChainableMockMethod3Common<void, P1, P2, P3>(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 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3) const { InvocationType inv(this->getMethodName(), p1, p2, p3); this->getCoreMock().invoke(inv); } }; } // ns mockpp #endif // MOCKPP_ChainableMockMethod3_H Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/chaining/Makefile.am,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Makefile.am 2 Oct 2005 10:57:51 -0000 1.12 +++ Makefile.am 25 Oct 2005 20:19:31 -0000 1.13 @@ -8,11 +8,21 @@ DynamicChainingMock.h DynamicChainingMockError.h FIFOInvocationDispatcher.h Invocation.h \ InvocationDispatcher.h InvocationMocker.h Invokable.h LIFOInvocationDispatcher.h \ StubMatchersCollection.h ChainableMockObject_macro.h mockpp_pti.h \ - ChainableMockMethod.h + ChainableMockMethod.h \ + ChainableMockMethod0.h \ + ChainableMockMethod1.h \ + ChainableMockMethod2.h \ + ChainableMockMethod3.h \ + ChainableMockMethod4.h \ + ChainableMockMethod5.h + +EXTRA_DIST = \ + gen_chainablemethod_N.pl libchainingincludedir = $(includedir)/mockpp/chaining CLEANFILES = *.~* *.~~* *~ *.old libchaining_la_SOURCES = ChainingMockObjectSupport.cpp Invocation.cpp + noinst_HEADERS = mockpp_pti.h --- NEW FILE: ChainableMockMethod4.h --- /** @file @brief Chainable Mock Method with 4 parameters. Generated with gen_chainablemethod_N.pl. $Id: ChainableMockMethod4.h,v 1.1 2005/10/25 20:19:31 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_ChainableMockMethod4_H #define MOCKPP_ChainableMockMethod4_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 4 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4> class ChainableMockMethod4Common : public ChainableMockMethodCommon<R> { public: typedef Invocation4<P1, P2, P3, P4> 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 */ ChainableMockMethod4Common(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 <ArgumentsMatchBuilder4<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(ChainableMockMethod4Common &method) : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) { } }; private: mutable CoreMockType coremock; }; /** Set up a chainable mock method expectations with 4 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4> class ChainableMockMethod4 : public ChainableMockMethod4Common<R, P1, P2, P3, P4> { public: typedef typename ChainableMockMethod4Common<R, P1, P2, P3, P4>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod4(const String &name, ChainableMockObject *parent ) : ChainableMockMethod4Common<R, P1, P2, P3, P4>(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 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) const { InvocationType inv(this->getMethodName(), p1, p2, p3, p4); return this->getCoreMock().invoke(inv); } }; /** Set up a chainable mock method expectations with 4 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3, typename P4> class ChainableMockMethod4<void, P1, P2, P3, P4> : public ChainableMockMethod4Common<void, P1, P2, P3, P4> { public: typedef typename ChainableMockMethod4Common<void, P1, P2, P3, P4>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod4(const String &name, ChainableMockObject *parent ) : ChainableMockMethod4Common<void, P1, P2, P3, P4>(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 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) const { InvocationType inv(this->getMethodName(), p1, p2, p3, p4); this->getCoreMock().invoke(inv); } }; } // ns mockpp #endif // MOCKPP_ChainableMockMethod4_H --- NEW FILE: gen_chainablemethod_N.pl --- #!/usr/bin/perl -w # # $Id: gen_chainablemethod_N.pl,v 1.1 2005/10/25 20:19:31 ewald-arnold Exp $ use English; if ($#ARGV < 0) { print "Usage: perl gen_Chainablemethod_N <number of arguments>\n"; exit; } $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } for ($numArgs = 0; $numArgs <= $totalNumArgs; ++$numArgs) { open OUT, ">ChainableMockMethod" . $numArgs . ".h"; print "Creating ChainableMockMethod" . $numArgs . ".h\n"; print OUT "/** \@file \@brief Chainable Mock Method with $numArgs parameters. Generated with gen_chainablemethod_N.pl. \$I" . "d: ChainableMockMethod" . $numArgs . ".h,v 1.7 2005/10/19 20:53:09 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_ChainableMockMethod" . $numArgs . "_H #define MOCKPP_ChainableMockMethod" . $numArgs . "_H #include <mockpp/mockpp.h> #include <mockpp/ChainableMockObject.h> #include <mockpp/chaining/ChainableMockMethod.h> namespace mockpp { "; $templateParms = ""; $templateParms_colon = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $templateParms .= ", "; } $templateParms .= "typename P$i"; } if ($numArgs > 0) { $templateParms_colon = ", " . $templateParms; } # print OUT "// templateParms: $templateParms\n"; $templateArgs_colon = ""; $_ = $templateParms; s/typename //g; $templateArgs = $_; if ($numArgs > 0) { $templateArgs_colon = ", ". $templateArgs; } # print OUT "// templateArgs: $templateArgs\n"; $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $parms .= ", "; } $parms .= "const P$i &p$i"; } # print OUT "// parms: $parms\n"; $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $holderParms .= ", "; } $holderParms .= "const ConstraintHolder<P$i> &p$i"; } # print OUT "// holderParms: $holderParms\n"; $args_colon = ""; $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $args .= ", "; } $args .= "p$i"; } if ($numArgs > 0) { $args_colon = ", ". $args; } # print OUT "// args: $args\n"; $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $boundArgs .= ", "; } $boundArgs .= "args->a$i"; } # print OUT "// boundArgs: $boundArgs\n"; $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } # print OUT "// argsAsMembers: $argsAsMembers\n"; $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $copyParms .= ", "; } $copyParms .= "P$i ia$i"; } # print OUT "// copyParms: $copyParms\n"; $initArgs = ""; if ($numArgs > 0) { $initArgs = ":"; } for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $initArgs .= ", "; } $initArgs .= "p$i(ip$i)"; } # print OUT "// initArgs: $initArgs\n"; $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argTypes .= "typedef P$i p". ($i+1) . "_type; "; } # print OUT "// argTypes: $argTypes\n\n\n"; print OUT "/** Common stuff to set up chainable mock method expectations with " . $numArgs . " parameters. * \@ingroup grp_controller */ template <typename R" . $templateParms_colon . "> class ChainableMockMethod" . $numArgs . "Common : public ChainableMockMethodCommon<R> { public: "; if ($numArgs > 0) { print OUT " typedef Invocation" . $numArgs . "<" . $templateArgs . "> InvocationType;"; } else { print OUT " typedef Invocation0 InvocationType;"; } print OUT " 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 */ ChainableMockMethod" . $numArgs . "Common(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 <ArgumentsMatchBuilder" . $numArgs . "<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(ChainableMockMethod" . $numArgs . "Common &method) : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) { } }; private: mutable CoreMockType coremock; }; /** Set up a chainable mock method expectations with " . $numArgs . " parameters. * \@ingroup grp_controller */ template <typename R" . $templateParms_colon . "> class ChainableMockMethod" . $numArgs . " : public ChainableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . "> { public: typedef typename ChainableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . ">::InvocationType InvocationType; /** Constructs the mock object. * \@param name human readable description about the expectation * \@param parent parent chainable mock object */ ChainableMockMethod" . $numArgs . "(const String &name, ChainableMockObject *parent ) : ChainableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . ">(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code."; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } print OUT " */ R forward(" . $parms . ") const { InvocationType inv(this->getMethodName()" . $args_colon . "); return this->getCoreMock().invoke(inv); } }; /** Set up a chainable mock method expectations with " . $numArgs . " parameters. * Partial specialisation for a void return value. * \@ingroup grp_controller */ template <" . $templateParms . "> class ChainableMockMethod" . $numArgs . "<void" . $templateArgs_colon . "> : public ChainableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . "> { public: "; if ($numArgs > 0) { print OUT " typedef typename ChainableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . ">::InvocationType InvocationType;"; } else { print OUT " typedef ChainableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . ">::InvocationType InvocationType;"; } print OUT " /** Constructs the mock object. * \@param name human readable description about the expectation * \@param parent parent chainable mock object */ ChainableMockMethod" . $numArgs . "(const String &name, ChainableMockObject *parent ) : ChainableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . ">(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code."; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } print OUT " */ void forward(" . $parms . ") const { InvocationType inv(this->getMethodName()" . $args_colon . "); this->getCoreMock().invoke(inv); } }; } // ns mockpp #endif // MOCKPP_ChainableMockMethod" . $numArgs . "_H "; close OUT; } --- NEW FILE: ChainableMockMethod5.h --- /** @file @brief Chainable Mock Method with 5 parameters. Generated with gen_chainablemethod_N.pl. $Id: ChainableMockMethod5.h,v 1.1 2005/10/25 20:19:31 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_ChainableMockMethod5_H #define MOCKPP_ChainableMockMethod5_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 5 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class ChainableMockMethod5Common : public ChainableMockMethodCommon<R> { public: typedef Invocation5<P1, P2, P3, P4, P5> 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 */ ChainableMockMethod5Common(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 <ArgumentsMatchBuilder5<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(ChainableMockMethod5Common &method) : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) { } }; private: mutable CoreMockType coremock; }; /** Set up a chainable mock method expectations with 5 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class ChainableMockMethod5 : public ChainableMockMethod5Common<R, P1, P2, P3, P4, P5> { public: typedef typename ChainableMockMethod5Common<R, P1, P2, P3, P4, P5>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod5(const String &name, ChainableMockObject *parent ) : ChainableMockMethod5Common<R, P1, P2, P3, P4, P5>(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 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const { InvocationType inv(this->getMethodName(), p1, p2, p3, p4, p5); return this->getCoreMock().invoke(inv); } }; /** Set up a chainable mock method expectations with 5 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3, typename P4, typename P5> class ChainableMockMethod5<void, P1, P2, P3, P4, P5> : public ChainableMockMethod5Common<void, P1, P2, P3, P4, P5> { public: typedef typename ChainableMockMethod5Common<void, P1, P2, P3, P4, P5>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod5(const String &name, ChainableMockObject *parent ) : ChainableMockMethod5Common<void, P1, P2, P3, P4, P5>(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 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const { InvocationType inv(this->getMethodName(), p1, p2, p3, p4, p5); this->getCoreMock().invoke(inv); } }; } // ns mockpp #endif // MOCKPP_ChainableMockMethod5_H --- NEW FILE: ChainableMockMethod0.h --- /** @file @brief Chainable Mock Method with 0 parameters. Generated with gen_chainablemethod_N.pl. $Id: ChainableMockMethod0.h,v 1.1 2005/10/25 20:19:31 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_ChainableMockMethod0_H #define MOCKPP_ChainableMockMethod0_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 0 parameters. * @ingroup grp_controller */ template <typename R> class ChainableMockMethod0Common : public ChainableMockMethodCommon<R> { public: typedef Invocation0 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 */ ChainableMockMethod0Common(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 <ArgumentsMatchBuilder0<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(ChainableMockMethod0Common &method) : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) { } }; private: mutable CoreMockType coremock; }; /** Set up a chainable mock method expectations with 0 parameters. * @ingroup grp_controller */ template <typename R> class ChainableMockMethod0 : public ChainableMockMethod0Common<R> { public: typedef typename ChainableMockMethod0Common<R>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod0(const String &name, ChainableMockObject *parent ) : ChainableMockMethod0Common<R>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. */ R forward() const { InvocationType inv(this->getMethodName()); return this->getCoreMock().invoke(inv); } }; /** Set up a chainable mock method expectations with 0 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <> class ChainableMockMethod0<void> : public ChainableMockMethod0Common<void> { public: typedef ChainableMockMethod0Common<void>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod0(const String &name, ChainableMockObject *parent ) : ChainableMockMethod0Common<void>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. */ void forward() const { InvocationType inv(this->getMethodName()); this->getCoreMock().invoke(inv); } }; } // ns mockpp #endif // MOCKPP_ChainableMockMethod0_H --- NEW FILE: ChainableMockMethod1.h --- /** @file @brief Chainable Mock Method with 1 parameters. Generated with gen_chainablemethod_N.pl. $Id: ChainableMockMethod1.h,v 1.1 2005/10/25 20:19:31 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_ChainableMockMethod1_H #define MOCKPP_ChainableMockMethod1_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 1 parameters. * @ingroup grp_controller */ template <typename R, typename P1> class ChainableMockMethod1Common : public ChainableMockMethodCommon<R> { public: typedef Invocation1<P1> 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 */ ChainableMockMethod1Common(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 <ArgumentsMatchBuilder1<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(ChainableMockMethod1Common &method) : Builder(&method.getCoreMock(), method.getChainableMockObject(), method.getMethodName()) { } }; private: mutable CoreMockType coremock; }; /** Set up a chainable mock method expectations with 1 parameters. * @ingroup grp_controller */ template <typename R, typename P1> class ChainableMockMethod1 : public ChainableMockMethod1Common<R, P1> { public: typedef typename ChainableMockMethod1Common<R, P1>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod1(const String &name, ChainableMockObject *parent ) : ChainableMockMethod1Common<R, P1>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 */ R forward(const P1 &p1) const { InvocationType inv(this->getMethodName(), p1); return this->getCoreMock().invoke(inv); } }; /** Set up a chainable mock method expectations with 1 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1> class ChainableMockMethod1<void, P1> : public ChainableMockMethod1Common<void, P1> { public: typedef typename ChainableMockMethod1Common<void, P1>::InvocationType InvocationType; /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ ChainableMockMethod1(const String &name, ChainableMockObject *parent ) : ChainableMockMethod1Common<void, P1>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 */ void forward(const P1 &p1) const { InvocationType inv(this->getMethodName(), p1); this->getCoreMock().invoke(inv); } }; } // ns mockpp #endif // MOCKPP_ChainableMockMethod1_H |
From: Ewald A. <ewa...@us...> - 2005-10-25 19:11:29
|
Update of /cvsroot/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv855 Modified Files: run-configure-unicode.sh Log Message: detect compiler Index: run-configure-unicode.sh =================================================================== RCS file: /cvsroot/mockpp/mockpp/run-configure-unicode.sh,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- run-configure-unicode.sh 19 Oct 2005 20:14:27 -0000 1.4 +++ run-configure-unicode.sh 25 Oct 2005 19:11:21 -0000 1.5 @@ -1,4 +1,11 @@ #!/bin/sh MYFLAGS="-O0 -g3 -Wall -Werror" -MYCC="ccache g++-4.0" + +if which "gcc-4.0"; then + MYCC="ccache g++-4.0"; +else + MYCC="ccache g++"; +fi +echo mycc: $MYCC + CFLAGS="$MYFLAGS" CXXFLAGS="$MYFLAGS" CXX=$MYCC CC=$MYCC ${0%/*}/configure --enable-unicode --enable-debug=full --prefix=/tmp/mockpp-install |
From: Ewald A. <ewa...@us...> - 2005-10-25 19:06:22
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31562/mockpp Modified Files: VisitableMockMethod.cpp VisitableMockMethod.h Log Message: basic file set working Index: VisitableMockMethod.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/VisitableMockMethod.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- VisitableMockMethod.cpp 17 Oct 2005 19:15:09 -0000 1.2 +++ VisitableMockMethod.cpp 25 Oct 2005 19:06:10 -0000 1.3 @@ -48,8 +48,15 @@ String MOCKPP_EXPORT VisitableMockMethodBase::getMethodName() const { -// static CppString method_name = getVerifiableName() + MOCKPP_PCHAR(".") + m_name; - return getVerifiableName(); + static String method_name = getVerifiableName(); // + MOCKPP_PCHAR(".") + m_name; + return method_name; +} + + +std::string MOCKPP_EXPORT VisitableMockMethodBase::getMethodIdentifier() const +{ + static std::string method_id = getLatin1(getMethodName()); + return method_id; } Index: VisitableMockMethod.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/VisitableMockMethod.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- VisitableMockMethod.h 24 Oct 2005 19:08:44 -0000 1.8 +++ VisitableMockMethod.h 25 Oct 2005 19:06:10 -0000 1.9 @@ -51,10 +51,39 @@ String getMethodName() const; + std::string getMethodIdentifier() const; + VisitableMockObject *getVisitableMockObject() const; + protected: + + void throwAvailableException() const + { + bool do_throw = true; + if (throwablesInline) + { + if (throwableInsteadReturn.size() != 0) + { + do_throw = throwableInsteadReturn[0]; + throwableInsteadReturn.erase(throwableInsteadReturn.begin()); + } + } + + if (do_throw && throwables.hasMoreObjects() != 0) + { + Throwable *thr = throwables.nextThrowableObject(); + if (thr != 0) + thr->throw_me(); + } + + if (defaultThrowable.get() != 0) + defaultThrowable.get()->throw_me(); + } + //------------------------------------------------------------- + public: + template <class VMM> class ControllerFor : public VisitableMockObject::Controller { @@ -128,48 +157,22 @@ } } - protected: - - void throwAvailableException() - { - bool do_throw = true; - if (this->method->throwablesInline) - { - if (throwableInsteadReturn.size() != 0) - { - do_throw = this->method->throwableInsteadReturn[0]; - this->method->throwableInsteadReturn.erase(this->method->throwableInsteadReturn.begin()); - } - } - - if (do_throw && this->method->throwables.hasMoreObjects() != 0) - { - Throwable *thr = this->method->throwables.nextThrowableObject(); - if (thr != 0) - thr->throw_me(); - } - - if (this->method->defaultThrowable.get() != 0) - this->method->defaultThrowable.get()->throw_me(); - } - - - protected: + protected: - VMM *method; - VisitableMockObject *object; + VMM *method; + VisitableMockObject *object; }; template <class VMM> friend class ControllerFor; - private: + private: - VisitableMockObject *visitable; - ThrowableItem defaultThrowable; - mutable ThrowableList throwables; - bool throwablesInline; - mutable std::vector<bool> throwableInsteadReturn; + VisitableMockObject *visitable; + mutable ThrowableItem defaultThrowable; + mutable ThrowableList throwables; + mutable bool throwablesInline; + mutable std::vector<bool> throwableInsteadReturn; }; @@ -187,7 +190,7 @@ */ VisitableMockReturningMethodBase(const String &name, VisitableMockObject *parent) : VisitableMockMethodBase(name, parent) - , returnValues(getMethodName() + MOCKPP_PCHAR("/returnValues")) + , returnValues(getMethodName() + MOCKPP_PCHAR("/returnValues"), this) {} class ControllerFor : public VisitableMockMethodBase::ControllerFor<VisitableMockReturningMethodBase> @@ -203,14 +206,14 @@ void setDefaultReturnValue(const R &rv) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->haveDefaultReturnValue = true; this->method->defaultReturnValue = rv; } void addReturnValue(const R &rv, unsigned count = 1) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); for ( ; count > 0; --count) { this->method->returnValues.addObjectToReturn(rv); |
From: Ewald A. <ewa...@us...> - 2005-10-25 19:05:47
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31298/mockpp Modified Files: gen_visitablemethod_N.pl Log Message: basic file set Index: gen_visitablemethod_N.pl =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/gen_visitablemethod_N.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gen_visitablemethod_N.pl 24 Oct 2005 19:08:44 -0000 1.3 +++ gen_visitablemethod_N.pl 25 Oct 2005 19:05:29 -0000 1.4 @@ -13,16 +13,16 @@ $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } - + for ($numArgs = 0; $numArgs <= $totalNumArgs; ++$numArgs) { open OUT, ">VisitableMockMethod" . $numArgs . ".h"; print "Creating VisitableMockMethod" . $numArgs . ".h\n"; -print OUT +print OUT "/** \@file \@brief Visitable Mock Method with $numArgs parameters. Generated with gen_visitablemethod_N.pl. - + \$I" . "d: VisitableMockMethod" . $numArgs . ".h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ @@ -61,7 +61,7 @@ namespace mockpp { - + "; $templateParms = ""; @@ -72,20 +72,20 @@ } $templateParms .= "typename P$i"; } - if ($numArgs > 0) { + if ($numArgs > 0) { $templateParms_colon = ", " . $templateParms; } -# print OUT "// templateParms: $templateParms\n"; - +# print OUT "// templateParms: $templateParms\n"; + $templateArgs_colon = ""; $_ = $templateParms; s/typename //g; $templateArgs = $_; - if ($numArgs > 0) { + if ($numArgs > 0) { $templateArgs_colon = ", ". $templateArgs; } -# print OUT "// templateArgs: $templateArgs\n"; - +# print OUT "// templateArgs: $templateArgs\n"; + $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { @@ -94,7 +94,7 @@ $parms .= "const P$i &p$i"; } -# print OUT "// parms: $parms\n"; +# print OUT "// parms: $parms\n"; $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -104,7 +104,7 @@ $holderParms .= "const ConstraintHolder<P$i> &p$i"; } -# print OUT "// holderParms: $holderParms\n"; +# print OUT "// holderParms: $holderParms\n"; $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -114,8 +114,8 @@ $args .= "p$i"; } -# print OUT "// args: $args\n"; - +# print OUT "// args: $args\n"; + $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { @@ -124,15 +124,15 @@ $boundArgs .= "args->a$i"; } -# print OUT "// boundArgs: $boundArgs\n"; +# print OUT "// boundArgs: $boundArgs\n"; $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } -# print OUT "// argsAsMembers: $argsAsMembers\n"; - +# print OUT "// argsAsMembers: $argsAsMembers\n"; + $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { @@ -141,7 +141,7 @@ $copyParms .= "P$i ia$i"; } -# print OUT "// copyParms: $copyParms\n"; +# print OUT "// copyParms: $copyParms\n"; $initArgs = ""; if ($numArgs > 0) { @@ -154,7 +154,7 @@ $initArgs .= "p$i(ip$i)"; } -# print OUT "// initArgs: $initArgs\n"; +# print OUT "// initArgs: $initArgs\n"; $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -163,8 +163,8 @@ # print OUT "// argTypes: $argTypes\n\n\n"; -print OUT -"/** Common stuf to set up visitable mock method expectations with " . $numArgs . " parameters. +print OUT +"/** Common stuff to set up visitable mock method expectations with " . $numArgs . " parameters. * \@ingroup grp_controller */ template <typename R" . $templateParms_colon . "> @@ -181,10 +181,10 @@ if ($numArgs > 0) { -print OUT " - , responseThrowables(this->getMethodName() + MOCKPP_PCHAR(\"/responseThrowables\") , this)"; +print OUT " + , responseThrowables(this->getMethodName() + MOCKPP_PCHAR(\"/responseThrowables\") , this)"; } - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " , parameter" . $p . "(this->getMethodName() + MOCKPP_PCHAR(\"/parameter" . $p . "\"), this)"; } @@ -193,16 +193,16 @@ } /** Set up expectations with constraints."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } - + print OUT " */ void forward (" . $holderParms . ") const { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); - this->getParent()->addExpectedMethod(this->getMethodName());"; + MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); + this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier());"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addExpected(p" . $p . ");"; } @@ -215,20 +215,19 @@ if ($numArgs > 0) { -print OUT " +print OUT " /** Perform the internals to verify a mocked method."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } - + print OUT " */ void forward_param(" . $parms . ") const { - - if (!this->method->isActivated() ) + if (!this->getVisitableMockObject()->isActivated() ) { - this->getParent()->addExpectedMethod(this->getMethodName());"; + this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier());"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addExpected(p" . $p . ");"; } @@ -240,7 +239,7 @@ { try { - this->getParent()->addActualMethod(this->getMethodName()); + this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, " . $args . ")) @@ -265,37 +264,37 @@ print OUT " } - }" ; -} + } +" ; +} else { print OUT " /** Perform the internals to verify a mocked method."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } - + print OUT " */ void forward_param(" . $parms . ") const { - - if (!this->method->isActivated() ) + if (!this->getVisitableMockObject()->isActivated() ) { - this->getParent()->addExpectedMethod(this->getMethodName()); + this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); } else { - this->getParent()->addActualMethod(this->getMethodName()); + this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); this->throwAvailableException(); } - }"; + }"; } print OUT " public: - + /** Helper object to easily set up the visitable expectations. * \@ingroup grp_controller */ @@ -304,63 +303,67 @@ public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; - + + /** Construct the controller object. + * \@meth poiinter to according method mock. + */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { - } -"; - + }"; + if ($numArgs > 0) { -print OUT " +print OUT " + /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * \@param t the throwable object"; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } - -print OUT " + +print OUT " * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, " . $args . ", count); } - + /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * \@param t the throwable object"; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " - * \@param p" . $p . " mock method parameter " . $p; } + * \@param p" . $p . " mock method parameter " . $p; } -print OUT " +print OUT " * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, " . $args . ", count); }"; } -print OUT " +print OUT " }; - friend class ControllerFor; -"; + friend class ControllerFor;"; if ($numArgs > 0) { print OUT " + private: - - mutable ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> responseThrowables;"; + + mutable ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> responseThrowables; +"; } for($p = 1; $p <= $numArgs; ++$p) { print OUT " @@ -374,7 +377,7 @@ * \@ingroup grp_controller */ template <typename R" . $templateParms_colon . "> -class VisitableMockMethod" . $numArgs . " +class VisitableMockMethod" . $numArgs . " : public VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . "> { public: @@ -385,19 +388,19 @@ */ VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . ">(name, parent)"; - + if ($numArgs > 0) { -print OUT " - , responseValues(this->getMethodName() + MOCKPP_PCHAR(\"/responseValues\") , this)"; +print OUT " + , responseValues(this->getMethodName() + MOCKPP_PCHAR(\"/responseValues\") , this)"; } - -print OUT " + +print OUT " { } /** Actually verifies the mocked method. Must be called by the client code."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } @@ -413,7 +416,7 @@ R ret_val; if (this->method->responseValues.find(ret_val, " . $args . ")) - return ret_val; + return ret_val; "; } @@ -429,32 +432,32 @@ public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; - - /** Helper object to easily set up the visitable expectations. - * \@ingroup grp_controller + + /** Construct the controller object. + * \@meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { }"; - + if ($numArgs > 0) { -print OUT " +print OUT " /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * \@param rv the return value"; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } -print OUT " +print OUT " * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, " . $args . ", count); } @@ -462,31 +465,32 @@ * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * \@param rv the return value"; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } -print OUT " +print OUT " * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, " . $args . ", count); } "; } -print OUT " +print OUT " }; friend class ControllerFor;"; if ($numArgs > 0) { -print OUT " +print OUT " + private: - + mutable ResponseVector" . $numArgs . "<R, " . $templateArgs . "> responseValues;"; } @@ -499,7 +503,7 @@ * \@ingroup grp_controller */ template <" . $templateParms . "> -class VisitableMockMethod" . $numArgs . "<void" . $templateArgs_colon . "> +class VisitableMockMethod" . $numArgs . "<void" . $templateArgs_colon . "> : public VisitableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . "> { public: @@ -514,7 +518,7 @@ } /** Actually verifies the mocked method. Must be called by the client code."; - + for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } @@ -533,15 +537,14 @@ public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; - - /** Helper object to easily set up the visitable expectations. - * \@ingroup grp_controller + + /** Construct the controller object. + * \@meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } - }; friend class ControllerFor; |
From: Ewald A. <ewa...@us...> - 2005-10-25 19:05:45
|
Update of /cvsroot/mockpp/mockpp/mockpp/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31298/mockpp/tests Modified Files: VisitableMockMethod_test.cpp Log Message: basic file set Index: VisitableMockMethod_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/VisitableMockMethod_test.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- VisitableMockMethod_test.cpp 19 Oct 2005 20:53:09 -0000 1.5 +++ VisitableMockMethod_test.cpp 25 Oct 2005 19:05:29 -0000 1.6 @@ -38,6 +38,13 @@ #else #include <mockpp/VisitableMockMethod.h> +#include <mockpp/VisitableMockMethod0.h> +#include <mockpp/VisitableMockMethod1.h> +#include <mockpp/VisitableMockMethod2.h> +#include <mockpp/VisitableMockMethod3.h> +#include <mockpp/VisitableMockMethod4.h> +#include <mockpp/VisitableMockMethod5.h> + #include <mockpp/VisitableMockObject.h> #include <mockpp/constraint/OutBound.h> @@ -61,12 +68,14 @@ // CPPUNIT_TEST( test_parameter_0 ); // CPPUNIT_TEST( test_parameter_0V ); CPPUNIT_TEST( test_base ); + CPPUNIT_TEST( test_inst ); CPPUNIT_TEST_SUITE_END(); public: void test_base(); + void test_inst(); // void test_parameter_0(); // void test_parameter_0V(); }; @@ -127,6 +136,25 @@ #endif +void VisitableMockMethod_test::test_inst() +{ + mockpp::VisitableMockMethod0<void> mmv0(MOCKPP_PCHAR("mm0"), 0); + mockpp::VisitableMockMethod1<void, int> mmv1(MOCKPP_PCHAR("mm1"), 0); + mockpp::VisitableMockMethod2<void, int, int> mmv2(MOCKPP_PCHAR("mm2"), 0); + mockpp::VisitableMockMethod3<void, int, int, int> mmv3(MOCKPP_PCHAR("mm3"), 0); + mockpp::VisitableMockMethod4<void, int, int, int, int> mmv4(MOCKPP_PCHAR("mm4"), 0); + mockpp::VisitableMockMethod5<void, int, int, int, int, int> mmv5(MOCKPP_PCHAR("mm5"), 0); + + mockpp::VisitableMockMethod0<int> mmi0(MOCKPP_PCHAR("mm0"), 0); + mockpp::VisitableMockMethod1<int, int> mmi1(MOCKPP_PCHAR("mm1"), 0); + mockpp::VisitableMockMethod2<int, int, int> mmi2(MOCKPP_PCHAR("mm2"), 0); + mockpp::VisitableMockMethod3<int, int, int, int> mmi3(MOCKPP_PCHAR("mm3"), 0); + mockpp::VisitableMockMethod4<int, int, int, int, int> mmi4(MOCKPP_PCHAR("mm4"), 0); + mockpp::VisitableMockMethod5<int, int, int, int, int, int> mmi5(MOCKPP_PCHAR("mm5"), 0); + +} + + void VisitableMockMethod_test::test_base() { mockpp::VisitableMockObject vmo (MOCKPP_PCHAR("mockobj"), 0); |
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30974/mockpp Added Files: VisitableMockMethod0.h VisitableMockMethod1.h VisitableMockMethod2.h VisitableMockMethod3.h VisitableMockMethod4.h VisitableMockMethod5.h Log Message: new --- NEW FILE: VisitableMockMethod2.h --- /** @file @brief Visitable Mock Method with 2 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod2.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 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_VisitableMockMethod2_H #define MOCKPP_VisitableMockMethod2_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector2.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 2 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2> class VisitableMockMethod2Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod2Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 */ void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 */ void forward_param(const P1 &p1, const P2 &p2) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1, p2)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); throw; } parameter1.addActual(p1); parameter2.addActual(p2); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector2<P1, P2> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; }; /** Set up visitable mock method expectations with 2 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2> class VisitableMockMethod2 : public VisitableMockMethod2Common<R, P1, P2> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod2(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod2Common<R, P1, P2>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 */ R forward(const P1 &p1, const P2 &p2) const { this->forward_param(p1, p2); R ret_val; if (this->method->responseValues.find(ret_val, p1, p2)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, count); } }; friend class ControllerFor; private: mutable ResponseVector2<R, P1, P2> responseValues; }; /** Set up visitable mock method expectations with 2 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2> class VisitableMockMethod2<void, P1, P2> : public VisitableMockMethod2Common<void, P1, P2> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod2(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod2Common<void, P1, P2>(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 */ void forward(const P1 &p1, const P2 &p2) const { this->forward_param(p1, p2); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod2_H --- NEW FILE: VisitableMockMethod3.h --- /** @file @brief Visitable Mock Method with 3 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod3.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 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_VisitableMockMethod3_H #define MOCKPP_VisitableMockMethod3_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector3.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 3 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3> class VisitableMockMethod3Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod3Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this) , parameter3(this->getMethodName() + MOCKPP_PCHAR("/parameter3"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 */ void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 */ void forward_param(const P1 &p1, const P2 &p2, const P3 &p3) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1, p2, p3)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); parameter3.balanceActual(); throw; } parameter1.addActual(p1); parameter2.addActual(p2); parameter3.addActual(p3); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector3<P1, P2, P3> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; mutable ConstraintList<P3> parameter3; }; /** Set up visitable mock method expectations with 3 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3> class VisitableMockMethod3 : public VisitableMockMethod3Common<R, P1, P2, P3> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod3(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod3Common<R, P1, P2, P3>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** 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 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3) const { this->forward_param(p1, p2, p3); R ret_val; if (this->method->responseValues.find(ret_val, p1, p2, p3)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, count); } }; friend class ControllerFor; private: mutable ResponseVector3<R, P1, P2, P3> responseValues; }; /** Set up visitable mock method expectations with 3 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3> class VisitableMockMethod3<void, P1, P2, P3> : public VisitableMockMethod3Common<void, P1, P2, P3> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod3(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod3Common<void, P1, P2, P3>(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 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3) const { this->forward_param(p1, p2, p3); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod3_H --- NEW FILE: VisitableMockMethod4.h --- /** @file @brief Visitable Mock Method with 4 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod4.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 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_VisitableMockMethod4_H #define MOCKPP_VisitableMockMethod4_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector4.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 4 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4> class VisitableMockMethod4Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod4Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this) , parameter3(this->getMethodName() + MOCKPP_PCHAR("/parameter3"), this) , parameter4(this->getMethodName() + MOCKPP_PCHAR("/parameter4"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 */ void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); parameter4.addExpected(p4); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 * @param p2 mock method parameter 2 * @param p3 mock method parameter 3 * @param p4 mock method parameter 4 */ void forward_param(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); parameter4.addExpected(p4); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1, p2, p3, p4)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); parameter3.balanceActual(); parameter4.balanceActual(); throw; } parameter1.addActual(p1); parameter2.addActual(p2); parameter3.addActual(p3); parameter4.addActual(p4); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @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 count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, p4, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @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 count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, p4, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector4<P1, P2, P3, P4> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; mutable ConstraintList<P3> parameter3; mutable ConstraintList<P4> parameter4; }; /** Set up visitable mock method expectations with 4 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4> class VisitableMockMethod4 : public VisitableMockMethod4Common<R, P1, P2, P3, P4> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod4(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod4Common<R, P1, P2, P3, P4>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** 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 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) const { this->forward_param(p1, p2, p3, p4); R ret_val; if (this->method->responseValues.find(ret_val, p1, p2, p3, p4)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @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 count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, p4, count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @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 count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, p4, count); } }; friend class ControllerFor; private: mutable ResponseVector4<R, P1, P2, P3, P4> responseValues; }; /** Set up visitable mock method expectations with 4 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3, typename P4> class VisitableMockMethod4<void, P1, P2, P3, P4> : public VisitableMockMethod4Common<void, P1, P2, P3, P4> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod4(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod4Common<void, P1, P2, P3, P4>(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 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) const { this->forward_param(p1, p2, p3, p4); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod4_H --- NEW FILE: VisitableMockMethod0.h --- /** @file @brief Visitable Mock Method with 0 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod0.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 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_VisitableMockMethod0_H #define MOCKPP_VisitableMockMethod0_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector0.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 0 parameters. * @ingroup grp_controller */ template <typename R> class VisitableMockMethod0Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod0Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) { } /** Set up expectations with constraints. */ void forward () const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); } protected: /** Perform the internals to verify a mocked method. */ void forward_param() const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); } else { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); this->throwAvailableException(); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; /** Set up visitable mock method expectations with 0 parameters. * @ingroup grp_controller */ template <typename R> class VisitableMockMethod0 : public VisitableMockMethod0Common<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod0(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod0Common<R>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. */ R forward() const { this->forward_param(); return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; /** Set up visitable mock method expectations with 0 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <> class VisitableMockMethod0<void> : public VisitableMockMethod0Common<void> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod0(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod0Common<void>(name, parent) { } /** Actually verifies the mocked method. Must be called by the client code. */ void forward() const { this->forward_param(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod0_H --- NEW FILE: VisitableMockMethod5.h --- /** @file @brief Visitable Mock Method with 5 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod5.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 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_VisitableMockMethod5_H #define MOCKPP_VisitableMockMethod5_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector5.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 5 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class VisitableMockMethod5Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod5Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) , parameter2(this->getMethodName() + MOCKPP_PCHAR("/parameter2"), this) , parameter3(this->getMethodName() + MOCKPP_PCHAR("/parameter3"), this) , parameter4(this->getMethodName() + MOCKPP_PCHAR("/parameter4"), this) , parameter5(this->getMethodName() + MOCKPP_PCHAR("/parameter5"), this) { } /** Set up expectations with constraints. * @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 */ void forward (const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); parameter4.addExpected(p4); parameter5.addExpected(p5); } protected: /** Perform the internals to verify a mocked method. * @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 */ void forward_param(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); parameter2.addExpected(p2); parameter3.addExpected(p3); parameter4.addExpected(p4); parameter5.addExpected(p5); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1, p2, p3, p4, p5)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); parameter3.balanceActual(); parameter4.balanceActual(); parameter5.balanceActual(); throw; } parameter1.addActual(p1); parameter2.addActual(p2); parameter3.addActual(p3); parameter4.addActual(p4); parameter5.addActual(p5); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @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 count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, p4, p5, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @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 count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, p2, p3, p4, p5, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector5<P1, P2, P3, P4, P5> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; mutable ConstraintList<P3> parameter3; mutable ConstraintList<P4> parameter4; mutable ConstraintList<P5> parameter5; }; /** Set up visitable mock method expectations with 5 parameters. * @ingroup grp_controller */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class VisitableMockMethod5 : public VisitableMockMethod5Common<R, P1, P2, P3, P4, P5> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod5(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod5Common<R, P1, P2, P3, P4, P5>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** 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 */ R forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const { this->forward_param(p1, p2, p3, p4, p5); R ret_val; if (this->method->responseValues.find(ret_val, p1, p2, p3, p4, p5)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @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 count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, p4, p5, count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @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 count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(rv, p1, p2, p3, p4, p5, count); } }; friend class ControllerFor; private: mutable ResponseVector5<R, P1, P2, P3, P4, P5> responseValues; }; /** Set up visitable mock method expectations with 5 parameters. * Partial specialisation for a void return value. * @ingroup grp_controller */ template <typename P1, typename P2, typename P3, typename P4, typename P5> class VisitableMockMethod5<void, P1, P2, P3, P4, P5> : public VisitableMockMethod5Common<void, P1, P2, P3, P4, P5> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod5(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod5Common<void, P1, P2, P3, P4, P5>(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 */ void forward(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) const { this->forward_param(p1, p2, p3, p4, p5); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) { } }; friend class ControllerFor; }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod5_H --- NEW FILE: VisitableMockMethod1.h --- /** @file @brief Visitable Mock Method with 1 parameters. Generated with gen_visitablemethod_N.pl. $Id: VisitableMockMethod1.h,v 1.1 2005/10/25 19:04:30 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 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_VisitableMockMethod1_H #define MOCKPP_VisitableMockMethod1_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> //#include <mockpp/ResponseVector1.h> namespace mockpp { /** Common stuff to set up visitable mock method expectations with 1 parameters. * @ingroup grp_controller */ template <typename R, typename P1> class VisitableMockMethod1Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod1Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseThrowables(this->getMethodName() + MOCKPP_PCHAR("/responseThrowables") , this) , parameter1(this->getMethodName() + MOCKPP_PCHAR("/parameter1"), this) { } /** Set up expectations with constraints. * @param p1 mock method parameter 1 */ void forward (const ConstraintHolder<P1> &p1) const { MOCKPP_ASSERT_FALSE(this->getVisitableMockObject()->isActivated()); this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); } protected: /** Perform the internals to verify a mocked method. * @param p1 mock method parameter 1 */ void forward_param(const P1 &p1) const { if (!this->getVisitableMockObject()->isActivated() ) { this->getVisitableMockObject()->addExpectedMethod(this->getMethodIdentifier()); parameter1.addExpected(p1); } else { try { this->getVisitableMockObject()->addActualMethod(this->getMethodIdentifier()); Throwable *t; if (this->responseValues.find(t, p1)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); throw; } parameter1.addActual(p1); } } public: /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const P1 &p1, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, count); } /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param t the throwable object * @param p1 mock method parameter 1 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, const ConstraintHolder<P1> &p1, unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->object->isActivated()); this->method->responseValues.add(t, p1, count); } }; friend class ControllerFor; private: mutable ResponseThrowableVector1<P1> responseThrowables; mutable ConstraintList<P1> parameter1; }; /** Set up visitable mock method expectations with 1 parameters. * @ingroup grp_controller */ template <typename R, typename P1> class VisitableMockMethod1 : public VisitableMockMethod1Common<R, P1> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent Visitable mock object */ VisitableMockMethod1(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod1Common<R, P1>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR("/responseValues") , this) { } /** Actually verifies the mocked method. Must be called by the client code. * @param p1 mock method parameter 1 */ R forward(const P1 &p1) const { this->forward_param(p1); R ret_val; if (this->method->responseValues.find(ret_val, p1)) return ret_val; return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. * @ingroup grp_controller */ class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; /** Construct the controller object. * @meth poiinter to according method mock. */ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) { } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. * @param rv the return value * @param p1 mock method parameter 1 * @param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, const P1 &p1, unsigned count = MOCKPP_UNLIMITED) ... [truncated message content] |
From: Ewald A. <ewa...@us...> - 2005-10-24 19:08:53
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15454/mockpp Modified Files: gen_visitablemethod_N.pl Makefile.am VisitableMockMethod.h Log Message: backup Index: VisitableMockMethod.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/VisitableMockMethod.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- VisitableMockMethod.h 19 Oct 2005 20:53:09 -0000 1.7 +++ VisitableMockMethod.h 24 Oct 2005 19:08:44 -0000 1.8 @@ -64,26 +64,26 @@ : method(meth) , object(meth->getVisitableMockObject()) { - object->addController(this); + this->object->addController(this); } virtual ~ControllerFor () { - object->removeController(this); + this->object->removeController(this); } void unsetThrowablesInline() { - MOCKPP_ASSERT_FALSE(object->isActivated()); - method->throwablesInline = false; + MOCKPP_ASSERT_FALSE(this->object->isActivated()); + this->method->throwablesInline = false; }; void addThrowable(Throwable *t_) { std::auto_ptr<Throwable> at (t_); - MOCKPP_ASSERT_FALSE(object->isActivated()); - method->throwables.push_back(at.release()); - method->throwableInsteadReturn.push_back(true); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); + this->method->throwables.push_back(at.release()); + this->method->throwableInsteadReturn.push_back(true); } template <class T> @@ -96,37 +96,66 @@ void setDefaultThrowable(Throwable *t_) { std::auto_ptr<Throwable> at (t_); - MOCKPP_ASSERT_FALSE(object->isActivated()); - method->defaultThrowable.take(at.release()); + MOCKPP_ASSERT_FALSE(this->object->isActivated()); + this->method->defaultThrowable.take(at.release()); } + /** Clears all expectations and puts the object in record mode again. */ virtual void reset() { - method->defaultThrowable.clear(); - method->throwables.clear(); - method->throwableInsteadReturn.clear(); - method->throwablesInline = true; + this->method->defaultThrowable.clear(); + this->method->throwables.clear(); + this->method->throwableInsteadReturn.clear(); + this->method->throwablesInline = true; } /** - * Verify the conditions which are not in the verify() chain. + * Verify the conditions which are not in the verify() chain of the + * visitable mock object. Located here instead of the method for traditional + * reasons. * If it fails, an AssertionFailedError is thrown */ virtual void verify() { - mockpp::Throwable *dt = method->defaultThrowable.get(); + Throwable *dt = this->method->defaultThrowable.get(); if (dt != 0) { String fmt = mockpp_i18n(MOCKPP_PCHAR("%1 is unused.")); - fmt << method->getMethodName() + MOCKPP_PCHAR("/defaultThrowable"); + fmt << this->method->getMethodName() + MOCKPP_PCHAR("/defaultThrowable"); MOCKPP_ASSERT_TRUE_MESSAGE(fmt, dt->hasThrown()); } } protected: + void throwAvailableException() + { + bool do_throw = true; + if (this->method->throwablesInline) + { + if (throwableInsteadReturn.size() != 0) + { + do_throw = this->method->throwableInsteadReturn[0]; + this->method->throwableInsteadReturn.erase(this->method->throwableInsteadReturn.begin()); + } + } + + if (do_throw && this->method->throwables.hasMoreObjects() != 0) + { + Throwable *thr = this->method->throwables.nextThrowableObject(); + if (thr != 0) + thr->throw_me(); + } + + if (this->method->defaultThrowable.get() != 0) + this->method->defaultThrowable.get()->throw_me(); + } + + + protected: + VMM *method; VisitableMockObject *object; }; @@ -174,17 +203,36 @@ void setDefaultReturnValue(const R &rv) { - MOCKPP_ASSERT_FALSE(this->object->isActivated()); + MOCKPP_ASSERT_FALSE(this->method->isActivated()); this->method->haveDefaultReturnValue = true; this->method->defaultReturnValue = rv; } + void addReturnValue(const R &rv, unsigned count = 1) + { + MOCKPP_ASSERT_FALSE(this->method->isActivated()); + for ( ; count > 0; --count) + { + this->method->returnValues.addObjectToReturn(rv); + this->method->throwableInsteadReturn.push_back(false); + } + } + + R determineReturnValue() + { + if (this->method->returnValues.hasMoreObjects()) + return this->method->returnValues.nextReturnObject(); + + MOCKPP_ASSERT_TRUE(this->method->haveDefaultReturnValue == true); + this->method->defaultReturnValueUsed = true; + return this->method->defaultReturnValue; + } + virtual void reset() { Inherited::reset(); this->method->haveDefaultReturnValue = false; this->method->defaultReturnValueUsed = false; - this->returnValues.clear(); } virtual void verify() @@ -196,8 +244,6 @@ fmt << this->method->getMethodName() + MOCKPP_PCHAR("/defaultReturnValueUsed"); MOCKPP_ASSERT_TRUE_MESSAGE(fmt, this->method->defaultReturnValueUsed); } - - this->returnvalues.verify(); } }; @@ -242,171 +288,6 @@ }; -////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifdef MOCKPP_XXX - -template <typename R, typename P1> -class VisitableMockMethod1 : public VisitableMockReturningMethodBase<R> -{ - public: - - /** Constructs the mock object. - * @param name human readable description about the expectation - * @param parent parent Visitable mock object - */ - VisitableMockMethod1(const String &name, VisitableMockObject *parent = 0) - : VisitableMockReturningMethodBase<R>(name, parent) - {} - - R forward(const P1 ¶m1) const - { - if (!isActivated() ) - { - getParent()->addExpectedMethod(getMethodName()); - Parameter1.addExpected(param1); - return; - } - - else - { - getParent()->addActualMethod(getMethodName()); - try - { - Throwable *t; - if (ResponseValues.find(t, (v_type1)param1)) - t->throw_me(); - - bool do_throw = true; - if (throwablesInline) - { - if (throwableInsteadReturn.size() != 0) - { - do_throw = ThrowableInsteadReturn[0]; - ThrowableInsteadReturn.erase(ThrowableInsteadReturn.begin()); - } - } - - if (do_throw && Throwables.hasMoreObjects() != 0) - { - Throwable *thr = throwables.nextThrowableObject(); - if (thr != 0) - thr->throw_me(); - } - - if (defaultThrowable.get() != 0) - defaultThrowable.get()->throw_me() - - } - - catch(...) - { - Parameter1.balanceActual(); - throw; - } - - Parameter1.addActual(param1); - return; - } - } - - R forward (const ConstraintHolder<v_type1> ¶m1) /* @todo const? */ - { - MOCKPP_ASSERT_FALSE(object->isActivated()); - getParent()->addExpectedMethod(getMethodName(); - Parameter1.addExpected(param1); - } - - class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor - { - public: - - }; - - private: - - mutable ResponseThrowableVector1< v_type1> responseValues; - mutable ConstraintList< type1 > parameter1; - } - - friend class ControllerFor; - - public: - - class ControllerFor : public VisitableMockObject::Controller - { - classname *object; - - public: - - ControllerFor (classname *cls) - : object(cls) - - public: - - void reset() - { - VisitableMockObject::Controller::reset(); - MOCKPP_ASSERT_FALSE(object->isActivated()); - object->ResponseValues.clear(); - object->Parameter1.clear(); - } - - virtual void verify() - { - VisitableMockObject::Controller::verify(); - Throwable *dt = object->defaultThrowable.get(); - if (dt != 0) - { - String fmt = mockpp_i18n(MOCKPP_PCHAR("%1 is unused.")); - fmt << MOCKPP_PCHAR(getMethodName()) MOCKPP_PCHAR("DefaultThrowable"); - MOCKPP_ASSERT_TRUE_MESSAGE(fmt, dt->hasThrown()); - } - } - - void addReturnValue(const ret_type &rv, unsigned count = 1) - { - MOCKPP_ASSERT_FALSE(object->isActivated()); - for ( ; count > 0; --count) - { - object->methReturnValues.addObjectToReturn(rv); - object->methThrowableInsteadReturn.push_back(false); - } - } - - void addResponseValue(const ret_type &rv, const type1 &p1, unsigned count = MOCKPP_UNLIMITED) - { - MOCKPP_ASSERT_FALSE(object->isActivated()); - object->methResponseValues.add(rv, (type1&)p1, count); - } - - void addResponseValue(const ret_type &rv, const ConstraintHolder< type1 > &p1, unsigned count = MOCKPP_UNLIMITED) - { - MOCKPP_ASSERT_FALSE(object->isActivated()); - object->methResponseValues.add(rv, p1, count); - } - - void addResponseThrowable(Throwable *t, const type1 &p1, unsigned count = MOCKPP_UNLIMITED) - { - MOCKPP_ASSERT_FALSE(object->isActivated()); - object->methResponseValues.add(t, (type1&)p1, count); - } - - void addResponseThrowable(Throwable *t, const ConstraintHolder< type1 > &p1, unsigned count = MOCKPP_UNLIMITED) - { - MOCKPP_ASSERT_FALSE(object->isActivated()); - object->methResponseValues.add(t, p1, count); - } - }; - - mutable ConstraintList< type1 > Parameter1 -}; - - -#endif - - } // namespace mockpp Index: gen_visitablemethod_N.pl =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/gen_visitablemethod_N.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gen_visitablemethod_N.pl 24 Oct 2005 17:24:57 -0000 1.2 +++ gen_visitablemethod_N.pl 24 Oct 2005 19:08:44 -0000 1.3 @@ -11,8 +11,12 @@ $totalNumArgs = $ARGV[0]; +if ($totalNumArgs < 5) { + $totalNumArgs = 5; } + for ($numArgs = 0; $numArgs <= $totalNumArgs; ++$numArgs) { open OUT, ">VisitableMockMethod" . $numArgs . ".h"; +print "Creating VisitableMockMethod" . $numArgs . ".h\n"; print OUT "/** \@file @@ -52,10 +56,11 @@ #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> -#include <mockpp/ResponseVector" . $numArgs . ".h> +//#include <mockpp/ResponseVector" . $numArgs . ".h> namespace mockpp { + "; @@ -70,7 +75,7 @@ if ($numArgs > 0) { $templateParms_colon = ", " . $templateParms; } -print OUT "// templateParms: $templateParms\n"; +# print OUT "// templateParms: $templateParms\n"; $templateArgs_colon = ""; $_ = $templateParms; @@ -79,7 +84,7 @@ if ($numArgs > 0) { $templateArgs_colon = ", ". $templateArgs; } -print OUT "// templateArgs: $templateArgs\n"; +# print OUT "// templateArgs: $templateArgs\n"; $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -89,7 +94,7 @@ $parms .= "const P$i &p$i"; } -print OUT "// parms: $parms\n"; +# print OUT "// parms: $parms\n"; $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -99,7 +104,7 @@ $holderParms .= "const ConstraintHolder<P$i> &p$i"; } -print OUT "// holderParms: $holderParms\n"; +# print OUT "// holderParms: $holderParms\n"; $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -109,7 +114,7 @@ $args .= "p$i"; } -print OUT "// args: $args\n"; +# print OUT "// args: $args\n"; $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -119,14 +124,14 @@ $boundArgs .= "args->a$i"; } -print OUT "// boundArgs: $boundArgs\n"; +# print OUT "// boundArgs: $boundArgs\n"; $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } -print OUT "// argsAsMembers: $argsAsMembers\n"; +# print OUT "// argsAsMembers: $argsAsMembers\n"; $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { @@ -136,7 +141,7 @@ $copyParms .= "P$i ia$i"; } -print OUT "// copyParms: $copyParms\n"; +# print OUT "// copyParms: $copyParms\n"; $initArgs = ""; if ($numArgs > 0) { @@ -149,17 +154,20 @@ $initArgs .= "p$i(ip$i)"; } -print OUT "// initArgs: $initArgs\n"; +# print OUT "// initArgs: $initArgs\n"; $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argTypes .= "typedef P$i p". ($i+1) . "_type; "; } -print OUT "// argTypes: $argTypes\n\n\n"; +# print OUT "// argTypes: $argTypes\n\n\n"; print OUT -"template <typename R" . $templateParms_colon . "> +"/** Common stuf to set up visitable mock method expectations with " . $numArgs . " parameters. + * \@ingroup grp_controller + */ +template <typename R" . $templateParms_colon . "> class VisitableMockMethod" . $numArgs . "Common : public VisitableMockReturningMethodBase<R> { public: @@ -169,16 +177,22 @@ * \@param parent parent Visitable mock object */ VisitableMockMethod" . $numArgs . "Common(const String &name, VisitableMockObject *parent = 0) - : VisitableMockReturningMethodBase<R>(name, parent) - , responseValues(this->getMethodName() + MOCKPP_PCHAR(\"/responseValues\") , this)"; + : VisitableMockReturningMethodBase<R>(name, parent)"; + if ($numArgs > 0) +{ +print OUT " + , responseThrowables(this->getMethodName() + MOCKPP_PCHAR(\"/responseThrowables\") , this)"; +} + for($p = 1; $p <= $numArgs; ++$p) { print OUT " , parameter" . $p . "(this->getMethodName() + MOCKPP_PCHAR(\"/parameter" . $p . "\"), this)"; } print OUT " - {} + { + } - /** Actually verifies the mocked method. Must be called by the client code."; + /** Set up expectations with constraints."; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } @@ -202,7 +216,7 @@ if ($numArgs > 0) { print OUT " - /** Actually verifies the mocked method. Must be called by the client code."; + /** Perform the internals to verify a mocked method."; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } @@ -212,7 +226,7 @@ void forward_param(" . $parms . ") const { - if (!this->object->isActivated() ) + if (!this->method->isActivated() ) { this->getParent()->addExpectedMethod(this->getMethodName());"; @@ -256,7 +270,7 @@ else { print OUT " - /** Actually verifies the mocked method. Must be called by the client code."; + /** Perform the internals to verify a mocked method."; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } @@ -266,7 +280,7 @@ void forward_param(" . $parms . ") const { - if (!this->object->isActivated() ) + if (!this->method->isActivated() ) { this->getParent()->addExpectedMethod(this->getMethodName()); } @@ -274,10 +288,12 @@ { this->getParent()->addActualMethod(this->getMethodName()); this->throwAvailableException(); - }"; + } + }"; } print OUT " + public: /** Helper object to easily set up the visitable expectations. @@ -291,9 +307,8 @@ ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) - {} - - friend class ControllerFor; + { + } "; if ($numArgs > 0) @@ -302,13 +317,13 @@ /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. - * \@param t the throable object"; + * \@param t the throwable object"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } print OUT " - * \@param count the number of times this value shall be returned. Default is unlimited. + * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) { @@ -319,13 +334,13 @@ /** Adds another response throwable. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. - * \@param t the throable object"; + * \@param t the throwable object"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } print OUT " - * \@param count the number of times this value shall be returned. Default is unlimited. + * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseThrowable(Throwable *t, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) { @@ -335,13 +350,19 @@ } print OUT " - }; - - protected: + }; - mutable ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> responseValues; + friend class ControllerFor; "; +if ($numArgs > 0) +{ +print OUT " + private: + + mutable ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> responseThrowables;"; +} + for($p = 1; $p <= $numArgs; ++$p) { print OUT " mutable ConstraintList<P" . $p . "> parameter" . $p . ";"; } @@ -349,6 +370,9 @@ }; +/** Set up visitable mock method expectations with " . $numArgs . " parameters. + * \@ingroup grp_controller + */ template <typename R" . $templateParms_colon . "> class VisitableMockMethod" . $numArgs . " : public VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . "> @@ -360,9 +384,17 @@ * \@param parent parent Visitable mock object */ VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) - : VisitableMockMethod1Common<R" . $templateArgs_colon . ">(name, parent) - {} - + : VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . ">(name, parent)"; + +if ($numArgs > 0) +{ +print OUT " + , responseValues(this->getMethodName() + MOCKPP_PCHAR(\"/responseValues\") , this)"; +} + +print OUT " + { + } /** Actually verifies the mocked method. Must be called by the client code."; @@ -371,22 +403,22 @@ print OUT " */ - void forward(" . $parms . ") const + R forward(" . $parms . ") const { - forward_param(" . $args . "); - "; + this->forward_param(" . $args . ");"; if ($numArgs > 0) { -print OUT " +print OUT " + R ret_val; if (this->method->responseValues.find(ret_val, " . $args . ")) - return ret_val; + return ret_val; "; } -print OUT " - return this->determineReturnValue(); +print OUT " + return this->determineReturnValue(); } /** Helper object to easily set up the visitable expectations. @@ -398,9 +430,13 @@ typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; - ControllerFor (VisitableMockReturningMethodBase<R> *meth) - : Inherited(meth) - {}"; + /** Helper object to easily set up the visitable expectations. + * \@ingroup grp_controller + */ + ControllerFor (VisitableMockReturningMethodBase<R> *meth) + : Inherited(meth) + { + }"; if ($numArgs > 0) { @@ -408,44 +444,60 @@ /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. - * \@param rv the return value"; + * \@param rv the return value"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } print OUT " - * \@param count the number of times this value shall be returned. Default is unlimited. + * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->method->isActivated()); - this->method->responseValues.add(t, " . $args . ", count); + this->method->responseValues.add(rv, " . $args . ", count); } /** Adds another response value. * Response values are determined on the parameters you pass. This way the * object returns a value that is totally based on the input. - * \@param rv the return value"; + * \@param rv the return value"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param p" . $p . " mock method parameter " . $p; } print OUT " - * \@param count the number of times this value shall be returned. Default is unlimited. + * \@param count the number of times this value shall be returned. Default is unlimited. */ void addResponseValue(const R &rv, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->method->isActivated()); - this->method->responseValues.add(t, " . $args . ", count); + this->method->responseValues.add(rv, " . $args . ", count); } "; } print OUT " - } + }; + + friend class ControllerFor;"; + +if ($numArgs > 0) +{ +print OUT " + private: + + mutable ResponseVector" . $numArgs . "<R, " . $templateArgs . "> responseValues;"; +} + +print OUT " }; +/** Set up visitable mock method expectations with " . $numArgs . " parameters. + * Partial specialisation for a void return value. + * \@ingroup grp_controller + */ template <" . $templateParms . "> class VisitableMockMethod" . $numArgs . "<void" . $templateArgs_colon . "> : public VisitableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . "> @@ -458,9 +510,20 @@ */ VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . ">(name, parent) - {} + { + } - public: + /** Actually verifies the mocked method. Must be called by the client code."; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } + +print OUT " + */ + void forward(" . $parms . ") const + { + this->forward_param(" . $args . "); + } /** Helper object to easily set up the visitable expectations. * \@ingroup grp_controller @@ -469,30 +532,19 @@ { public: - typedef typename VisitableMockReturningMethodBase<void>::ControllerFor Inherited; + typedef VisitableMockReturningMethodBase<void>::ControllerFor Inherited; /** Helper object to easily set up the visitable expectations. * \@ingroup grp_controller */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) - {} + { + } }; friend class ControllerFor; - - /** Actually verifies the mocked method. Must be called by the client code."; - -for($p = 1; $p <= $numArgs; ++$p) { print OUT " - * \@param p" . $p . " mock method parameter " . $p; } - -print OUT " - */ - void forward(" . $parms . ") const - { - forward_param(" . $args . "); - } }; Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/Makefile.am,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -r1.89 -r1.90 --- Makefile.am 23 Oct 2005 12:08:51 -0000 1.89 +++ Makefile.am 24 Oct 2005 19:08:44 -0000 1.90 @@ -31,7 +31,13 @@ ExpectationCounter.h mockpp.h Throwable.h ThrowableList.h MockObject.h VisitableMockObject.h \ VerifiableList.h Verifiable.h VerifyingTestCase.h SelfDescribing.h ChainableMockObject.h \ VerifyingTestCaller.h TrackingCounter.h MixedMockObject.h mockpp_dbc.h MockTimeServer.h \ - VisitableMockMethod.h + VisitableMockMethod.h \ + VisitableMockMethod0.h \ + VisitableMockMethod1.h \ + VisitableMockMethod2.h \ + VisitableMockMethod3.h \ + VisitableMockMethod4.h \ + VisitableMockMethod5.h EXTRA_DIST = \ mockpp_config-bcb5.h \ @@ -40,7 +46,8 @@ visitable-template.h \ visitable-template.raw \ chainable-template.h \ - chainable-template.raw + chainable-template.raw \ + gen_visitablemethod_N.pl CLEANFILES = *.~* *.~~* *~ mockpp_config.h *.old |
From: Ewald A. <ewa...@us...> - 2005-10-24 17:25:09
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24379/mockpp Modified Files: gen_visitablemethod_N.pl Log Message: update Index: gen_visitablemethod_N.pl =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/gen_visitablemethod_N.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gen_visitablemethod_N.pl 23 Oct 2005 19:42:38 -0000 1.1 +++ gen_visitablemethod_N.pl 24 Oct 2005 17:24:57 -0000 1.2 @@ -1,5 +1,6 @@ #!/usr/bin/perl -w # +# $Id$ use English; @@ -15,10 +16,10 @@ print OUT "/** \@file - \@brief Visitable Mock Methods for $numArgs parameter. + \@brief Visitable Mock Method with $numArgs parameters. Generated with gen_visitablemethod_N.pl. - \$Id$numArgs . ".h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ + \$I" . "d: VisitableMockMethod" . $numArgs . ".h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ @@ -51,6 +52,7 @@ #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> +#include <mockpp/ResponseVector" . $numArgs . ".h> namespace mockpp { @@ -58,20 +60,24 @@ "; $templateParms = ""; + $templateParms_colon = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $templateParms .= ", "; } $templateParms .= "typename P$i"; } -$templateParms_colon = ", ". $templateParms; + if ($numArgs > 0) { + $templateParms_colon = ", " . $templateParms; } print OUT "// templateParms: $templateParms\n"; + $templateArgs_colon = ""; $_ = $templateParms; s/typename //g; $templateArgs = $_; -$templateArgs_colon = ", ". $templateArgs; + if ($numArgs > 0) { + $templateArgs_colon = ", ". $templateArgs; } print OUT "// templateArgs: $templateArgs\n"; @@ -147,8 +153,7 @@ $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { - $argTypes .= "typedef P$i p". ($i+1) . "_type; "; - } + $argTypes .= "typedef P$i p". ($i+1) . "_type; "; } print OUT "// argTypes: $argTypes\n\n\n"; @@ -167,21 +172,28 @@ : VisitableMockReturningMethodBase<R>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR(\"/responseValues\") , this)"; -for($p = 1; $p <= $numArgs; ++$p) { print OUT " +for($p = 1; $p <= $numArgs; ++$p) { print OUT " , parameter" . $p . "(this->getMethodName() + MOCKPP_PCHAR(\"/parameter" . $p . "\"), this)"; } -print OUT " +print OUT " {} + /** Actually verifies the mocked method. Must be called by the client code."; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } + +print OUT " + */ void forward (" . $holderParms . ") const { MOCKPP_ASSERT_FALSE(this->method->isActivated()); this->getParent()->addExpectedMethod(this->getMethodName());"; -for($p = 1; $p <= $numArgs; ++$p) { print OUT " +for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addExpected(p" . $p . ");"; } -print OUT " +print OUT " } protected: @@ -190,6 +202,13 @@ if ($numArgs > 0) { print OUT " + /** Actually verifies the mocked method. Must be called by the client code."; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } + +print OUT " + */ void forward_param(" . $parms . ") const { @@ -200,7 +219,7 @@ for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addExpected(p" . $p . ");"; } -print OUT " +print OUT " } else @@ -219,24 +238,31 @@ catch(...) {"; -for($p = 1; $p <= $numArgs; ++$p) { print OUT " +for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".balanceActual();"; } -print OUT " +print OUT " throw; } "; -for($p = 1; $p <= $numArgs; ++$p) { print OUT " +for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addActual(p" . $p . ");"; } -print OUT " +print OUT " } }" ; } else { -print OUT " +print OUT " + /** Actually verifies the mocked method. Must be called by the client code."; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } + +print OUT " + */ void forward_param(" . $parms . ") const { @@ -251,35 +277,61 @@ }"; } - -print OUT " +print OUT " public: - class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor - { - public: + /** Helper object to easily set up the visitable expectations. + * \@ingroup grp_controller + */ + class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor + { + public: - typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; - + typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; + ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) - {} + {} + + friend class ControllerFor; "; if ($numArgs > 0) { print OUT " - void addResponseThrowable(Throwable *t, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) - { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); - this->method->responseValues.add(t, " . $args . ", count); - } + /** Adds another response throwable. + * Response values are determined on the parameters you pass. This way the + * object returns a value that is totally based on the input. + * \@param t the throable object"; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } + +print OUT " + * \@param count the number of times this value shall be returned. Default is unlimited. + */ + void addResponseThrowable(Throwable *t, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) + { + MOCKPP_ASSERT_FALSE(this->method->isActivated()); + this->method->responseValues.add(t, " . $args . ", count); + } + + /** Adds another response throwable. + * Response values are determined on the parameters you pass. This way the + * object returns a value that is totally based on the input. + * \@param t the throable object"; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } - void addResponseThrowable(Throwable *t, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) - { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); - this->method->responseValues.add(t, " . $args . ", count); - }"; +print OUT " + * \@param count the number of times this value shall be returned. Default is unlimited. + */ + void addResponseThrowable(Throwable *t, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) + { + MOCKPP_ASSERT_FALSE(this->method->isActivated()); + this->method->responseValues.add(t, " . $args . ", count); + }"; } print OUT " @@ -290,7 +342,7 @@ mutable ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> responseValues; "; -for($p = 1; $p <= $numArgs; ++$p) { print OUT " +for($p = 1; $p <= $numArgs; ++$p) { print OUT " mutable ConstraintList<P" . $p . "> parameter" . $p . ";"; } print OUT " @@ -298,7 +350,8 @@ template <typename R" . $templateParms_colon . "> -class VisitableMockMethod" . $numArgs . " : public VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . "> +class VisitableMockMethod" . $numArgs . " + : public VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . "> { public: @@ -307,94 +360,139 @@ * \@param parent parent Visitable mock object */ VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) - : VisitableMockMethod1Common<R, " . $templateArgs . ">(name, parent) + : VisitableMockMethod1Common<R" . $templateArgs_colon . ">(name, parent) {} + /** Actually verifies the mocked method. Must be called by the client code."; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } + +print OUT " + */ void forward(" . $parms . ") const { forward_param(" . $args . "); - -"; + "; if ($numArgs > 0) { print OUT " R ret_val; if (this->method->responseValues.find(ret_val, " . $args . ")) - return ret_val;"; + return ret_val; +"; } print OUT " return this->determineReturnValue(); } - class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor - { - public: + /** Helper object to easily set up the visitable expectations. + * \@ingroup grp_controller + */ + class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor + { + public: - typedef typename VisitableMockReturningMethodBase<void>::ControllerFor Inherited; - - ControllerFor (VisitableMockReturningMethodBase<void> *meth) - : Inherited(meth) - {}"; - + typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; + + ControllerFor (VisitableMockReturningMethodBase<R> *meth) + : Inherited(meth) + {}"; + if ($numArgs > 0) { print OUT " - void addResponseValue(const R &rv, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) - { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); - this->method->responseValues.add(t, " . $args . ", count); - } + /** Adds another response value. + * Response values are determined on the parameters you pass. This way the + * object returns a value that is totally based on the input. + * \@param rv the return value"; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } - void addResponseValue(const R &rv, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) - { - MOCKPP_ASSERT_FALSE(this->method->isActivated()); - this->method->responseValues.add(t, " . $args . ", count); - } +print OUT " + * \@param count the number of times this value shall be returned. Default is unlimited. + */ + void addResponseValue(const R &rv, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) + { + MOCKPP_ASSERT_FALSE(this->method->isActivated()); + this->method->responseValues.add(t, " . $args . ", count); + } + + /** Adds another response value. + * Response values are determined on the parameters you pass. This way the + * object returns a value that is totally based on the input. + * \@param rv the return value"; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } + +print OUT " + * \@param count the number of times this value shall be returned. Default is unlimited. + */ + void addResponseValue(const R &rv, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) + { + MOCKPP_ASSERT_FALSE(this->method->isActivated()); + this->method->responseValues.add(t, " . $args . ", count); + } "; } print OUT " - } -} + } +}; + + template <" . $templateParms . "> -class VisitableMockMethod" . $numArgs . "<void, " . $templateArgs . "> - : public VisitableMockMethod" . $numArgs . "Common<void, " . $templateArgs . "> +class VisitableMockMethod" . $numArgs . "<void" . $templateArgs_colon . "> + : public VisitableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . "> { public: - /** Constructs the mock object. - * \@param name human readable description about the expectation - * \@param parent parent Visitable mock object - */ - VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) - : VisitableMockMethod" . $numArgs . "Common<void, " . $templateArgs . ">(name, parent) - {} - - - class ControllerFor; + /** Constructs the mock object. + * \@param name human readable description about the expectation + * \@param parent parent Visitable mock object + */ + VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) + : VisitableMockMethod" . $numArgs . "Common<void" . $templateArgs_colon . ">(name, parent) + {} - public: + public: - class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor - { - public: + /** Helper object to easily set up the visitable expectations. + * \@ingroup grp_controller + */ + class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor + { + public: - typedef typename VisitableMockReturningMethodBase<void>::ControllerFor Inherited; - + typedef typename VisitableMockReturningMethodBase<void>::ControllerFor Inherited; + + /** Helper object to easily set up the visitable expectations. + * \@ingroup grp_controller + */ ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) - {} - - }; + {} + + }; + + friend class ControllerFor; + /** Actually verifies the mocked method. Must be called by the client code."; + +for($p = 1; $p <= $numArgs; ++$p) { print OUT " + * \@param p" . $p . " mock method parameter " . $p; } + +print OUT " + */ void forward(" . $parms . ") const { forward_param(" . $args . "); } - }; |
From: Ewald A. <ewa...@us...> - 2005-10-23 19:42:46
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2168/mockpp Added Files: gen_visitablemethod_N.pl Log Message: new --- NEW FILE: gen_visitablemethod_N.pl --- #!/usr/bin/perl -w # use English; if ($#ARGV < 0) { print "Usage: perl gen_visitablemethod_N <number of arguments>\n"; exit; } $totalNumArgs = $ARGV[0]; for ($numArgs = 0; $numArgs <= $totalNumArgs; ++$numArgs) { open OUT, ">VisitableMockMethod" . $numArgs . ".h"; print OUT "/** \@file \@brief Visitable Mock Methods for $numArgs parameter. Generated with gen_visitablemethod_N.pl. \$Id: gen_visitablemethod_N.pl,v 1.1 2005/10/23 19:42:38 ewald-arnold Exp $numArgs . ".h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ /************************************************************************** begin : Thu Oct 22 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_VisitableMockMethod" . $numArgs . "_H #define MOCKPP_VisitableMockMethod" . $numArgs . "_H #include <mockpp/mockpp.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/VisitableMockMethod.h> namespace mockpp { "; $templateParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $templateParms .= ", "; } $templateParms .= "typename P$i"; } $templateParms_colon = ", ". $templateParms; print OUT "// templateParms: $templateParms\n"; $_ = $templateParms; s/typename //g; $templateArgs = $_; $templateArgs_colon = ", ". $templateArgs; print OUT "// templateArgs: $templateArgs\n"; $parms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $parms .= ", "; } $parms .= "const P$i &p$i"; } print OUT "// parms: $parms\n"; $holderParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $holderParms .= ", "; } $holderParms .= "const ConstraintHolder<P$i> &p$i"; } print OUT "// holderParms: $holderParms\n"; $args = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $args .= ", "; } $args .= "p$i"; } print OUT "// args: $args\n"; $boundArgs = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $boundArgs .= ", "; } $boundArgs .= "args->a$i"; } print OUT "// boundArgs: $boundArgs\n"; $argsAsMembers = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argsAsMembers .= "P$i p$i;"; } print OUT "// argsAsMembers: $argsAsMembers\n"; $copyParms = ""; for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $copyParms .= ", "; } $copyParms .= "P$i ia$i"; } print OUT "// copyParms: $copyParms\n"; $initArgs = ""; if ($numArgs > 0) { $initArgs = ":"; } for ($i = 1; $i <= $numArgs; ++$i) { if ($i > 1) { $initArgs .= ", "; } $initArgs .= "p$i(ip$i)"; } print OUT "// initArgs: $initArgs\n"; $argTypes = ""; for ($i = 1; $i <= $numArgs; ++$i) { $argTypes .= "typedef P$i p". ($i+1) . "_type; "; } print OUT "// argTypes: $argTypes\n\n\n"; print OUT "template <typename R" . $templateParms_colon . "> class VisitableMockMethod" . $numArgs . "Common : public VisitableMockReturningMethodBase<R> { public: /** Constructs the mock object. * \@param name human readable description about the expectation * \@param parent parent Visitable mock object */ VisitableMockMethod" . $numArgs . "Common(const String &name, VisitableMockObject *parent = 0) : VisitableMockReturningMethodBase<R>(name, parent) , responseValues(this->getMethodName() + MOCKPP_PCHAR(\"/responseValues\") , this)"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " , parameter" . $p . "(this->getMethodName() + MOCKPP_PCHAR(\"/parameter" . $p . "\"), this)"; } print OUT " {} void forward (" . $holderParms . ") const { MOCKPP_ASSERT_FALSE(this->method->isActivated()); this->getParent()->addExpectedMethod(this->getMethodName());"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addExpected(p" . $p . ");"; } print OUT " } protected: "; if ($numArgs > 0) { print OUT " void forward_param(" . $parms . ") const { if (!this->object->isActivated() ) { this->getParent()->addExpectedMethod(this->getMethodName());"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addExpected(p" . $p . ");"; } print OUT " } else { try { this->getParent()->addActualMethod(this->getMethodName()); Throwable *t; if (this->responseValues.find(t, " . $args . ")) t->throw_me(); this->throwAvailableException(); } catch(...) {"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".balanceActual();"; } print OUT " throw; } "; for($p = 1; $p <= $numArgs; ++$p) { print OUT " parameter" . $p . ".addActual(p" . $p . ");"; } print OUT " } }" ; } else { print OUT " void forward_param(" . $parms . ") const { if (!this->object->isActivated() ) { this->getParent()->addExpectedMethod(this->getMethodName()); } else { this->getParent()->addActualMethod(this->getMethodName()); this->throwAvailableException(); }"; } print OUT " public: class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<R>::ControllerFor Inherited; ControllerFor (VisitableMockReturningMethodBase<R> *meth) : Inherited(meth) {} "; if ($numArgs > 0) { print OUT " void addResponseThrowable(Throwable *t, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->method->isActivated()); this->method->responseValues.add(t, " . $args . ", count); } void addResponseThrowable(Throwable *t, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->method->isActivated()); this->method->responseValues.add(t, " . $args . ", count); }"; } print OUT " }; protected: mutable ResponseThrowableVector" . $numArgs . "<" . $templateArgs . "> responseValues; "; for($p = 1; $p <= $numArgs; ++$p) { print OUT " mutable ConstraintList<P" . $p . "> parameter" . $p . ";"; } print OUT " }; template <typename R" . $templateParms_colon . "> class VisitableMockMethod" . $numArgs . " : public VisitableMockMethod" . $numArgs . "Common<R" . $templateArgs_colon . "> { public: /** Constructs the mock object. * \@param name human readable description about the expectation * \@param parent parent Visitable mock object */ VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod1Common<R, " . $templateArgs . ">(name, parent) {} void forward(" . $parms . ") const { forward_param(" . $args . "); "; if ($numArgs > 0) { print OUT " R ret_val; if (this->method->responseValues.find(ret_val, " . $args . ")) return ret_val;"; } print OUT " return this->determineReturnValue(); } class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<void>::ControllerFor Inherited; ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) {}"; if ($numArgs > 0) { print OUT " void addResponseValue(const R &rv, " . $parms . ", unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->method->isActivated()); this->method->responseValues.add(t, " . $args . ", count); } void addResponseValue(const R &rv, " . $holderParms . ", unsigned count = MOCKPP_UNLIMITED) { MOCKPP_ASSERT_FALSE(this->method->isActivated()); this->method->responseValues.add(t, " . $args . ", count); } "; } print OUT " } } template <" . $templateParms . "> class VisitableMockMethod" . $numArgs . "<void, " . $templateArgs . "> : public VisitableMockMethod" . $numArgs . "Common<void, " . $templateArgs . "> { public: /** Constructs the mock object. * \@param name human readable description about the expectation * \@param parent parent Visitable mock object */ VisitableMockMethod" . $numArgs . "(const String &name, VisitableMockObject *parent = 0) : VisitableMockMethod" . $numArgs . "Common<void, " . $templateArgs . ">(name, parent) {} class ControllerFor; public: class ControllerFor : public VisitableMockReturningMethodBase<void>::ControllerFor { public: typedef typename VisitableMockReturningMethodBase<void>::ControllerFor Inherited; ControllerFor (VisitableMockReturningMethodBase<void> *meth) : Inherited(meth) {} }; void forward(" . $parms . ") const { forward_param(" . $args . "); } }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod" . $numArgs . "_H "; close OUT; } |
From: Ewald A. <ewa...@us...> - 2005-10-23 12:08:59
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7737/mockpp Modified Files: Makefile.am Log Message: prevent examples from compiling Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/Makefile.am,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- Makefile.am 15 Oct 2005 15:13:26 -0000 1.88 +++ Makefile.am 23 Oct 2005 12:08:51 -0000 1.89 @@ -1,8 +1,8 @@ INCLUDES = $(all_includes) -I$(top_srcdir) -I$(top_builddir) $(EA_EXTRA_INC) DEFAULT_INCLUDES = $(INCLUDES) -SUBDIRS = chaining compat util builder constraint matcher stub production . docs tests po \ - examples +SUBDIRS = chaining compat util builder constraint matcher stub production . docs tests po +# examples lib_LTLIBRARIES = libmockpp.la |
From: Ewald A. <ewa...@us...> - 2005-10-23 12:04:03
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5748/mockpp Modified Files: VisitableMockObject.h Log Message: docs Index: VisitableMockObject.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/VisitableMockObject.h,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- VisitableMockObject.h 17 Oct 2005 19:14:19 -0000 1.40 +++ VisitableMockObject.h 23 Oct 2005 12:03:42 -0000 1.41 @@ -205,7 +205,9 @@ virtual void unsetThrowablesInline() = 0; /** - * Verify the conditions which are not in the verify() chain. + * Verify the conditions which are not in the verify() chain of the + * visitable mock object. Located here instead of the object for traditional + * reasons. * If it fails, an AssertionFailedError is thrown */ virtual void verify() = 0; |