[Mockpp-commits] mockpp/mockpp/constraint ConstraintSetN.h,NONE,1.1 gen_constraintset_N.pl,NONE,1.1
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-10-29 18:16:31
|
Update of /cvsroot/mockpp/mockpp/mockpp/constraint In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10934/mockpp/constraint Modified Files: ConstraintSet.h Makefile.am Added Files: ConstraintSetN.h gen_constraintset_N.pl Log Message: basic file set working --- NEW FILE: gen_constraintset_N.pl --- #!/usr/bin/perl -w # # $Id: gen_constraintset_N.pl,v 1.1 2005/10/29 18:16:22 ewald-arnold Exp $ use English; if ($#ARGV < 0) { print "Usage: perl gen_constraintset_N <number of arguments>\n"; exit; } $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } open OUT, ">ConstraintSetN.h"; print OUT "/** \@file \@internal NOT INTENDED FOR PUBLIC INCLUSION \@brief Generated with gen_constraintset_N.pl. \$I" . "d: ConstraintSetN.h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ /************************************************************************** begin : Sat Aug 21 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_ConstraintSet_N_H #define MOCKPP_ConstraintSet_N_H //#include <mockpp/builder/ConstraintSet.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 ConstraintSet" . $numArgs ."\n"; print OUT " /** A set of constraints for a method with " . $numArgs . " arguments * \@internal */ template <" . $templateParms . "> class ConstraintSet" . $numArgs . " { public: "; for($p = 1; $p <= $numArgs; ++$p) { print OUT " typedef P" . $p . " ValueType" . $p . ";"; } print OUT " /** Constructs the object"; for($p = 1; $p <= $numArgs; ++$p) { print OUT " * \@param in_constraint" . $p . " constraint " . $p . ""; } print OUT " */ ConstraintSet" . $numArgs . "( const ConstraintHolder<P1> &in_constraint1"; for($p = 2; $p <= $numArgs; ++$p) { print OUT " , const ConstraintHolder<P" . $p . "> &in_constraint" . $p; } print OUT ") : constraint1( in_constraint1 )"; for($p = 2; $p <= $numArgs; ++$p) { print OUT " , constraint" . $p . "( in_constraint" . $p . " )"; } print OUT " {} /** Destroys the object */ virtual ~ConstraintSet" . $numArgs . "() {} /** Tests if the constraint set matches the invocation * \@param invocation the invocation data * \@return true: the set matches */ template <typename I> // Invocation bool matches( const I &invocation ) { return constraint1->eval( invocation.getParameter1() )"; for($p = 2; $p <= $numArgs; ++$p) { print OUT " && constraint" . $p . "->eval( invocation.getParameter" . $p . "() )"; } print OUT "; } /** Appends the description of this object to the buffer. * \@param buffer The buffer that the description is appended to. * \@return The current content of the buffer data */ virtual String describeTo( String &buffer ) const { String fmt = MOCKPP_PCHAR( \"" . $percentParms . "\" ); fmt << constraint1->toString()"; for($p = 2; $p <= $numArgs; ++$p) { print OUT " << constraint" . $p . "->toString()"; } print OUT "; buffer += fmt; return buffer; } private: "; for($p = 1; $p <= $numArgs; ++$p) { print OUT " const typename Constraint<P" . $p . ">::AP constraint" . $p . ";"; } print OUT " }; "; } print OUT " } // ns mockpp #endif // MOCKPP_ConstraintSet_N_H "; close OUT; Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/constraint/Makefile.am,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Makefile.am 19 Sep 2005 18:34:35 -0000 1.12 +++ Makefile.am 29 Oct 2005 18:16:22 -0000 1.13 @@ -6,9 +6,12 @@ libconstraintinclude_HEADERS = IsAnything.h IsCloseTo.h IsEqual.h \ IsGreaterThan.h IsInstanceOf.h IsLessThan.h IsNot.h IsNothing.h IsSame.h Or.h \ StringContains.h StringStartsWith.h StringEndsWith.h And.h IsGreaterOrEqual.h \ - IsLessOrEqual.h Constraint.h ConstraintSet.h OutBound.h \ + IsLessOrEqual.h Constraint.h ConstraintSet.h ConstraintSetN.h OutBound.h \ TypelessConstraint.h ConstraintHolder.h ConstraintList.h +EXTRA_DIST = \ + gen_constraintset_N.pl + CLEANFILES = *.~* *.~~* *~ *.old libconstraintincludedir = $(includedir)/mockpp/constraint --- NEW FILE: ConstraintSetN.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_constraintset_N.pl. $Id: ConstraintSetN.h,v 1.1 2005/10/29 18:16:22 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Aug 21 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_ConstraintSet_N_H #define MOCKPP_ConstraintSet_N_H //#include <mockpp/builder/ConstraintSet.h> namespace mockpp { /** A set of constraints for a method with 1 arguments * @internal */ template <typename P1> class ConstraintSet1 { public: typedef P1 ValueType1; /** Constructs the object * @param in_constraint1 constraint 1 */ ConstraintSet1( const ConstraintHolder<P1> &in_constraint1) : constraint1( in_constraint1 ) {} /** Destroys the object */ virtual ~ConstraintSet1() {} /** Tests if the constraint set matches the invocation * @param invocation the invocation data * @return true: the set matches */ template <typename I> // Invocation bool matches( const I &invocation ) { return constraint1->eval( invocation.getParameter1() ); } /** Appends the description of this object to the buffer. * @param buffer The buffer that the description is appended to. * @return The current content of the buffer data */ virtual String describeTo( String &buffer ) const { String fmt = MOCKPP_PCHAR( "%1" ); fmt << constraint1->toString(); buffer += fmt; return buffer; } private: const typename Constraint<P1>::AP constraint1; }; /** A set of constraints for a method with 2 arguments * @internal */ template <typename P1, typename P2> class ConstraintSet2 { public: typedef P1 ValueType1; typedef P2 ValueType2; /** Constructs the object * @param in_constraint1 constraint 1 * @param in_constraint2 constraint 2 */ ConstraintSet2( const ConstraintHolder<P1> &in_constraint1 , const ConstraintHolder<P2> &in_constraint2) : constraint1( in_constraint1 ) , constraint2( in_constraint2 ) {} /** Destroys the object */ virtual ~ConstraintSet2() {} /** Tests if the constraint set matches the invocation * @param invocation the invocation data * @return true: the set matches */ template <typename I> // Invocation bool matches( const I &invocation ) { return constraint1->eval( invocation.getParameter1() ) && constraint2->eval( invocation.getParameter2() ); } /** Appends the description of this object to the buffer. * @param buffer The buffer that the description is appended to. * @return The current content of the buffer data */ virtual String describeTo( String &buffer ) const { String fmt = MOCKPP_PCHAR( "%1, %2" ); fmt << constraint1->toString() << constraint2->toString(); buffer += fmt; return buffer; } private: const typename Constraint<P1>::AP constraint1; const typename Constraint<P2>::AP constraint2; }; /** A set of constraints for a method with 3 arguments * @internal */ template <typename P1, typename P2, typename P3> class ConstraintSet3 { public: typedef P1 ValueType1; typedef P2 ValueType2; typedef P3 ValueType3; /** Constructs the object * @param in_constraint1 constraint 1 * @param in_constraint2 constraint 2 * @param in_constraint3 constraint 3 */ ConstraintSet3( const ConstraintHolder<P1> &in_constraint1 , const ConstraintHolder<P2> &in_constraint2 , const ConstraintHolder<P3> &in_constraint3) : constraint1( in_constraint1 ) , constraint2( in_constraint2 ) , constraint3( in_constraint3 ) {} /** Destroys the object */ virtual ~ConstraintSet3() {} /** Tests if the constraint set matches the invocation * @param invocation the invocation data * @return true: the set matches */ template <typename I> // Invocation bool matches( const I &invocation ) { return constraint1->eval( invocation.getParameter1() ) && constraint2->eval( invocation.getParameter2() ) && constraint3->eval( invocation.getParameter3() ); } /** Appends the description of this object to the buffer. * @param buffer The buffer that the description is appended to. * @return The current content of the buffer data */ virtual String describeTo( String &buffer ) const { String fmt = MOCKPP_PCHAR( "%1, %2, %3" ); fmt << constraint1->toString() << constraint2->toString() << constraint3->toString(); buffer += fmt; return buffer; } private: const typename Constraint<P1>::AP constraint1; const typename Constraint<P2>::AP constraint2; const typename Constraint<P3>::AP constraint3; }; /** A set of constraints for a method with 4 arguments * @internal */ template <typename P1, typename P2, typename P3, typename P4> class ConstraintSet4 { public: typedef P1 ValueType1; typedef P2 ValueType2; typedef P3 ValueType3; typedef P4 ValueType4; /** Constructs the object * @param in_constraint1 constraint 1 * @param in_constraint2 constraint 2 * @param in_constraint3 constraint 3 * @param in_constraint4 constraint 4 */ ConstraintSet4( const ConstraintHolder<P1> &in_constraint1 , const ConstraintHolder<P2> &in_constraint2 , const ConstraintHolder<P3> &in_constraint3 , const ConstraintHolder<P4> &in_constraint4) : constraint1( in_constraint1 ) , constraint2( in_constraint2 ) , constraint3( in_constraint3 ) , constraint4( in_constraint4 ) {} /** Destroys the object */ virtual ~ConstraintSet4() {} /** Tests if the constraint set matches the invocation * @param invocation the invocation data * @return true: the set matches */ template <typename I> // Invocation bool matches( const I &invocation ) { return constraint1->eval( invocation.getParameter1() ) && constraint2->eval( invocation.getParameter2() ) && constraint3->eval( invocation.getParameter3() ) && constraint4->eval( invocation.getParameter4() ); } /** Appends the description of this object to the buffer. * @param buffer The buffer that the description is appended to. * @return The current content of the buffer data */ virtual String describeTo( String &buffer ) const { String fmt = MOCKPP_PCHAR( "%1, %2, %3, %4" ); fmt << constraint1->toString() << constraint2->toString() << constraint3->toString() << constraint4->toString(); buffer += fmt; return buffer; } private: const typename Constraint<P1>::AP constraint1; const typename Constraint<P2>::AP constraint2; const typename Constraint<P3>::AP constraint3; const typename Constraint<P4>::AP constraint4; }; /** A set of constraints for a method with 5 arguments * @internal */ template <typename P1, typename P2, typename P3, typename P4, typename P5> class ConstraintSet5 { public: typedef P1 ValueType1; typedef P2 ValueType2; typedef P3 ValueType3; typedef P4 ValueType4; typedef P5 ValueType5; /** Constructs the object * @param in_constraint1 constraint 1 * @param in_constraint2 constraint 2 * @param in_constraint3 constraint 3 * @param in_constraint4 constraint 4 * @param in_constraint5 constraint 5 */ ConstraintSet5( const ConstraintHolder<P1> &in_constraint1 , const ConstraintHolder<P2> &in_constraint2 , const ConstraintHolder<P3> &in_constraint3 , const ConstraintHolder<P4> &in_constraint4 , const ConstraintHolder<P5> &in_constraint5) : constraint1( in_constraint1 ) , constraint2( in_constraint2 ) , constraint3( in_constraint3 ) , constraint4( in_constraint4 ) , constraint5( in_constraint5 ) {} /** Destroys the object */ virtual ~ConstraintSet5() {} /** Tests if the constraint set matches the invocation * @param invocation the invocation data * @return true: the set matches */ template <typename I> // Invocation bool matches( const I &invocation ) { return constraint1->eval( invocation.getParameter1() ) && constraint2->eval( invocation.getParameter2() ) && constraint3->eval( invocation.getParameter3() ) && constraint4->eval( invocation.getParameter4() ) && constraint5->eval( invocation.getParameter5() ); } /** Appends the description of this object to the buffer. * @param buffer The buffer that the description is appended to. * @return The current content of the buffer data */ virtual String describeTo( String &buffer ) const { String fmt = MOCKPP_PCHAR( "%1, %2, %3, %4, %5" ); fmt << constraint1->toString() << constraint2->toString() << constraint3->toString() << constraint4->toString() << constraint5->toString(); buffer += fmt; return buffer; } private: const typename Constraint<P1>::AP constraint1; const typename Constraint<P2>::AP constraint2; const typename Constraint<P3>::AP constraint3; const typename Constraint<P4>::AP constraint4; const typename Constraint<P5>::AP constraint5; }; /** A set of constraints for a method with 6 arguments * @internal */ template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> class ConstraintSet6 { public: typedef P1 ValueType1; typedef P2 ValueType2; typedef P3 ValueType3; typedef P4 ValueType4; typedef P5 ValueType5; typedef P6 ValueType6; /** Constructs the object * @param in_constraint1 constraint 1 * @param in_constraint2 constraint 2 * @param in_constraint3 constraint 3 * @param in_constraint4 constraint 4 * @param in_constraint5 constraint 5 * @param in_constraint6 constraint 6 */ ConstraintSet6( const ConstraintHolder<P1> &in_constraint1 , const ConstraintHolder<P2> &in_constraint2 , const ConstraintHolder<P3> &in_constraint3 , const ConstraintHolder<P4> &in_constraint4 , const ConstraintHolder<P5> &in_constraint5 , const ConstraintHolder<P6> &in_constraint6) : constraint1( in_constraint1 ) , constraint2( in_constraint2 ) , constraint3( in_constraint3 ) , constraint4( in_constraint4 ) , constraint5( in_constraint5 ) , constraint6( in_constraint6 ) {} /** Destroys the object */ virtual ~ConstraintSet6() {} /** Tests if the constraint set matches the invocation * @param invocation the invocation data * @return true: the set matches */ template <typename I> // Invocation bool matches( const I &invocation ) { return constraint1->eval( invocation.getParameter1() ) && constraint2->eval( invocation.getParameter2() ) && constraint3->eval( invocation.getParameter3() ) && constraint4->eval( invocation.getParameter4() ) && constraint5->eval( invocation.getParameter5() ) && constraint6->eval( invocation.getParameter6() ); } /** Appends the description of this object to the buffer. * @param buffer The buffer that the description is appended to. * @return The current content of the buffer data */ virtual String describeTo( String &buffer ) const { String fmt = MOCKPP_PCHAR( "%1, %2, %3, %4, %5, %6" ); fmt << constraint1->toString() << constraint2->toString() << constraint3->toString() << constraint4->toString() << constraint5->toString() << constraint6->toString(); buffer += fmt; return buffer; } private: const typename Constraint<P1>::AP constraint1; const typename Constraint<P2>::AP constraint2; const typename Constraint<P3>::AP constraint3; const typename Constraint<P4>::AP constraint4; const typename Constraint<P5>::AP constraint5; const typename Constraint<P6>::AP constraint6; }; } // ns mockpp #endif // MOCKPP_ConstraintSet_N_H Index: ConstraintSet.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/constraint/ConstraintSet.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- ConstraintSet.h 19 Oct 2005 20:14:27 -0000 1.15 +++ ConstraintSet.h 29 Oct 2005 18:16:22 -0000 1.16 @@ -71,342 +71,11 @@ }; -/////////////////////////////////////////////////////////////////// - - -/** A set of constraints for a method with 1 argument - * @internal - */ -template <typename T1> -class ConstraintSet1 -{ - public: - - typedef T1 ValueType1; - - /** Constructs the object - * @param in_constraint1 constraint 1 - */ - ConstraintSet1( const ConstraintHolder<T1> &in_constraint1 ) - : constraint1( in_constraint1 ) - {} - - /** Destroys the object - */ - virtual ~ConstraintSet1() - {} - - /** Tests if the constraint set matches the invocation - * @param invocation the invocation data - * @return true: the set matches - */ - template <typename I> // Invocation - bool matches( const I &invocation ) - { - return constraint1->eval( invocation.getParameter1() ); - } - - /** Appends the description of this object to the buffer. - * @param buffer The buffer that the description is appended to. - * @return The current content of the buffer data - */ - virtual String describeTo( String &buffer ) const - { - String fmt = MOCKPP_PCHAR( "%1" ); - fmt << constraint1->toString(); - buffer += fmt; - return buffer; - } - - private: - - const typename Constraint<T1>::AP constraint1; -}; - - -/////////////////////////////////////////////////////////////////// - - -/** A set of constraints for a method with 2 argument - * @internal - */ -template <typename T1, typename T2> -class ConstraintSet2 -{ - public: - - typedef T1 ValueType1; - typedef T2 ValueType2; - - /** Constructs the object - * @param in_constraint1 constraint 1 - * @param in_constraint2 constraint 2 - */ - ConstraintSet2( const ConstraintHolder<T1> &in_constraint1, - const ConstraintHolder<T2> &in_constraint2 ) - : constraint1( in_constraint1 ) - , constraint2( in_constraint2 ) - {} - - /** Destroys the object - */ - virtual ~ConstraintSet2() - {} - - /** Tests if the constraint set matches the invocation - * @param invocation the invocation data - * @return true: the set matches - */ - template <typename I> // Invocation - bool matches( const I &invocation ) - { - return constraint1->eval( invocation.getParameter1() ) - && constraint2->eval( invocation.getParameter2() ); - } - - /** Appends the description of this object to the buffer. - * @param buffer The buffer that the description is appended to. - * @return The current content of the buffer data - */ - virtual String describeTo( String &buffer ) const - { - String fmt = MOCKPP_PCHAR( "%1, %2" ); - fmt << constraint1->toString() - << constraint2->toString(); - buffer += fmt; - return buffer; - } - - private: - - const typename Constraint<T1>::AP constraint1; - const typename Constraint<T2>::AP constraint2; -}; - - -/////////////////////////////////////////////////////////////////// - - -/** A set of constraints for a method with 3 argument - * @internal - */ -template <typename T1, typename T2, typename T3> -class ConstraintSet3 -{ - public: - - typedef T1 ValueType1; - typedef T2 ValueType2; - typedef T3 ValueType3; - - /** Constructs the object - * @param in_constraint1 constraint 1 - * @param in_constraint2 constraint 2 - * @param in_constraint3 constraint 3 - */ - ConstraintSet3( const ConstraintHolder<T1> &in_constraint1, - const ConstraintHolder<T2> &in_constraint2, - const ConstraintHolder<T3> &in_constraint3 ) - : constraint1( in_constraint1 ) - , constraint2( in_constraint2 ) - , constraint3( in_constraint3 ) - {} - - /** Destroys the object - */ - virtual ~ConstraintSet3() - {} - - /** Tests if the constraint set matches the invocation - * @param invocation the invocation data - * @return true: the set matches - */ - template <typename I> // Invocation - bool matches( const I &invocation ) - { - return constraint1->eval( invocation.getParameter1() ) - && constraint2->eval( invocation.getParameter2() ) - && constraint3->eval( invocation.getParameter3() ); - } - - /** Appends the description of this object to the buffer. - * @param buffer The buffer that the description is appended to. - * @return The current content of the buffer data - */ - virtual String describeTo( String &buffer ) const - { - String fmt = MOCKPP_PCHAR( "%1, %2, %3" ); - fmt << constraint1->toString() - << constraint2->toString() - << constraint3->toString(); - buffer += fmt; - return buffer; - } - - private: - - const typename Constraint<T1>::AP constraint1; - const typename Constraint<T2>::AP constraint2; - const typename Constraint<T3>::AP constraint3; -}; - - -/////////////////////////////////////////////////////////////////// - - -/** A set of constraints for a method with 4 argument - * @internal - */ -template <typename T1, typename T2, typename T3, typename T4> -class ConstraintSet4 -{ - public: - - typedef T1 ValueType1; - typedef T2 ValueType2; - typedef T3 ValueType3; - typedef T4 ValueType4; - - /** Constructs the object - * @param in_constraint1 constraint 1 - * @param in_constraint2 constraint 2 - * @param in_constraint3 constraint 3 - * @param in_constraint4 constraint 4 - */ - ConstraintSet4( const ConstraintHolder<T1> &in_constraint1, - const ConstraintHolder<T2> &in_constraint2, - const ConstraintHolder<T3> &in_constraint3, - const ConstraintHolder<T4> &in_constraint4 ) - : constraint1( in_constraint1 ) - , constraint2( in_constraint2 ) - , constraint3( in_constraint3 ) - , constraint4( in_constraint4 ) - {} - - /** Destroys the object - */ - virtual ~ConstraintSet4() - {} - - /** Tests if the constraint set matches the invocation - * @param invocation the invocation data - * @return true: the set matches - */ - template <typename I> // Invocation - bool matches( const I &invocation ) - { - return constraint1->eval( invocation.getParameter1() ) - && constraint2->eval( invocation.getParameter2() ) - && constraint3->eval( invocation.getParameter3() ) - && constraint4->eval( invocation.getParameter4() ); - } - - /** Appends the description of this object to the buffer. - * @param buffer The buffer that the description is appended to. - * @return The current content of the buffer data - */ - virtual String describeTo( String &buffer ) const - { - String fmt = MOCKPP_PCHAR( "%1, %2, %3, %4" ); - fmt << constraint1->toString() - << constraint2->toString() - << constraint3->toString() - << constraint4->toString(); - buffer += fmt; - return buffer; - } - - private: - - const typename Constraint<T1>::AP constraint1; - const typename Constraint<T2>::AP constraint2; - const typename Constraint<T3>::AP constraint3; - const typename Constraint<T4>::AP constraint4; -}; - - -/////////////////////////////////////////////////////////////////// - - -/** A set of constraints for a method with 5 argument - * @internal - */ -template <typename T1, typename T2, typename T3, typename T4, typename T5> -class ConstraintSet5 -{ - public: - - typedef T1 ValueType1; - typedef T2 ValueType2; - typedef T3 ValueType3; - typedef T4 ValueType4; - typedef T5 ValueType5; - - /** Constructs the object - * @param in_constraint1 constraint 1 - * @param in_constraint2 constraint 2 - * @param in_constraint3 constraint 3 - * @param in_constraint4 constraint 4 - * @param in_constraint5 constraint 5 - */ - ConstraintSet5( const ConstraintHolder<T1> &in_constraint1, - const ConstraintHolder<T2> &in_constraint2, - const ConstraintHolder<T3> &in_constraint3, - const ConstraintHolder<T4> &in_constraint4, - const ConstraintHolder<T5> &in_constraint5 ) - : constraint1( in_constraint1 ) - , constraint2( in_constraint2 ) - , constraint3( in_constraint3 ) - , constraint4( in_constraint4 ) - , constraint5( in_constraint5 ) - {} - - /** Destroys the object - */ - virtual ~ConstraintSet5() - {} - - /** Tests if the constraint set matches the invocation - * @param invocation the invocation data - * @return true: the set matches - */ - template <typename I> // Invocation - bool matches( const I &invocation ) - { - return constraint1->eval( invocation.getParameter1() ) - && constraint2->eval( invocation.getParameter2() ) - && constraint3->eval( invocation.getParameter3() ) - && constraint4->eval( invocation.getParameter4() ) - && constraint5->eval( invocation.getParameter5() ); - } - - /** Appends the description of this object to the buffer. - * @param buffer The buffer that the description is appended to. - * @return The current content of the buffer data - */ - virtual String describeTo( String &buffer ) const - { - String fmt = MOCKPP_PCHAR( "%1, %2, %3, %4, %5" ); - fmt << constraint1->toString() - << constraint2->toString() - << constraint3->toString() - << constraint4->toString() - << constraint5->toString(); - buffer += fmt; - return buffer; - } - - private: - - const typename Constraint<T1>::AP constraint1; - const typename Constraint<T2>::AP constraint2; - const typename Constraint<T3>::AP constraint3; - const typename Constraint<T4>::AP constraint4; - const typename Constraint<T5>::AP constraint5; -}; - } // namespace mockpp #endif // MOCKPP_CONSTRAINTSET_H + + +#include "ConstraintSetN.h" |