mockpp-commits Mailing List for Mock Objects for C++ (Page 15)
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
|
From: Ewald A. <ewa...@us...> - 2005-12-10 20:07:29
|
Update of /cvsroot/mockpp/mockpp/3party/cxxtest/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7221/3party/cxxtest/docs Modified Files: Makefile.am Log Message: restructuring and cleanup Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/docs/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 9 Dec 2005 20:40:42 -0000 1.2 +++ Makefile.am 10 Dec 2005 20:07:21 -0000 1.3 @@ -1,7 +1,7 @@ -EXTRA_DIST= - guide.html \ - index.html \ - qt2.png \ - qt.png \ - win32.png \ - x11.png +EXTRA_DIST= \ + guide.html \ + index.html \ + qt2.png \ + qt.png \ + win32.png \ + x11.png |
From: Ewald A. <ewa...@us...> - 2005-12-10 20:07:29
|
Update of /cvsroot/mockpp/mockpp/3party/cxxtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7221/3party/cxxtest Modified Files: Makefile.am Log Message: restructuring and cleanup Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 9 Dec 2005 16:19:17 -0000 1.1 +++ Makefile.am 10 Dec 2005 20:07:21 -0000 1.2 @@ -1 +1 @@ -SUBDIRS = cxxtest +SUBDIRS = cxxtest docs |
From: Ewald A. <ewa...@us...> - 2005-12-10 20:07:28
|
Update of /cvsroot/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7221 Modified Files: ChangeLog Makefile.am configure.in gen_files_N.sh Log Message: restructuring and cleanup Index: ChangeLog =================================================================== RCS file: /cvsroot/mockpp/mockpp/ChangeLog,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- ChangeLog 8 Dec 2005 17:33:59 -0000 1.84 +++ ChangeLog 10 Dec 2005 20:07:20 -0000 1.85 @@ -11,6 +11,10 @@ - optionally disable exceptions - project files MSVC2005 Express (free as in beer) - fixed compilation problem with msvc + - removed msvc6/7/bcb6/bcbX project trees (not working/supported) + - compatibility break: moved all visitable files to mockpp/visiting + - compatibility break: moved all chainableable files to mockpp/chaining + - compatibility break: moved all framework related files to mockpp/framework 2005-11-19 1.10.0: Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/Makefile.am,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- Makefile.am 8 Dec 2005 17:33:59 -0000 1.37 +++ Makefile.am 10 Dec 2005 20:07:20 -0000 1.38 @@ -1,4 +1,4 @@ -SUBDIRS = tool config 3party mockpp bcb5 bcb6 bcbX msvc6 msvc7 msvc71 msvc2005 +SUBDIRS = tool config 3party mockpp bcb5 msvc71 msvc2005 LIBTOOL_DEPS = @LIBTOOL_DEPS@ Index: gen_files_N.sh =================================================================== RCS file: /cvsroot/mockpp/mockpp/gen_files_N.sh,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gen_files_N.sh 30 Oct 2005 13:53:00 -0000 1.3 +++ gen_files_N.sh 10 Dec 2005 20:07:20 -0000 1.4 @@ -15,10 +15,10 @@ ( cd mockpp/chaining ; ./gen_invocation_N.pl $p ) ( cd mockpp/chaining ; ./gen_chainablemethod_N.pl $p ) ( cd mockpp/chaining ; ./gen_countchainable_N.pl $p ) -( cd mockpp ; ./gen_responsevector_N.pl $p ) -( cd mockpp ; ./gen_visitablemethod_N.pl $p ) +( cd mockpp/visiting ; ./gen_responsevector_N.pl $p ) +( cd mockpp/visiting ; ./gen_visitablemethod_N.pl $p ) +( cd mockpp/visiting ; ./gen_countvisitable_N.pl $p ) ( cd mockpp/builder ; ./gen_argumentsmatchbuilder_N.pl $p ) ( cd mockpp/constraint ; ./gen_constraintset_N.pl $p ) ( cd mockpp ; ./gen_countparams_N.pl $p ) -( cd mockpp ; ./gen_countvisitable_N.pl $p ) Index: configure.in =================================================================== RCS file: /cvsroot/mockpp/mockpp/configure.in,v retrieving revision 1.103 retrieving revision 1.104 diff -u -d -r1.103 -r1.104 --- configure.in 10 Dec 2005 15:18:52 -0000 1.103 +++ configure.in 10 Dec 2005 20:07:20 -0000 1.104 @@ -442,10 +442,6 @@ Makefile \ \ bcb5/Makefile \ - bcb6/Makefile \ - \ - bcbX/Makefile \ - bcbX/cppunit-lib/Makefile \ \ 3party/Makefile \ 3party/ministl/Makefile \ @@ -458,15 +454,6 @@ config/Makefile \ tool/Makefile \ \ - msvc6/Makefile \ - msvc6/lib/Makefile \ - msvc6/mockpp/Makefile \ - msvc6/mockpp/examples/Makefile \ - msvc6/mockpp/examples/tutorial/Makefile \ - msvc6/mockpp/tests/Makefile \ - \ - msvc7/Makefile \ - \ msvc71/Makefile \ msvc71/lib/Makefile \ msvc71/mockpp/Makefile \ @@ -489,6 +476,7 @@ mockpp/docs/en/images/callouts/Makefile \ \ mockpp/po/Makefile \ + mockpp/config/Makefile \ mockpp/tests/Makefile \ mockpp/examples/Makefile \ mockpp/examples/tutorial/Makefile \ @@ -496,7 +484,9 @@ mockpp/Makefile \ mockpp/util/Makefile \ mockpp/compat/Makefile \ + mockpp/visiting/Makefile \ \ + mockpp/framework/Makefile \ mockpp/production/Makefile \ \ mockpp/chaining/Makefile \ |
Update of /cvsroot/mockpp/mockpp/mockpp/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32577/mockpp/framework Added Files: CxxTestSupport.h SelectUnittestFramework.h VerifyingTestCaller.cpp VerifyingTestCaller.h VerifyingTestCase.cpp VerifyingTestCase.h Log Message: moved to subdir framework --- NEW FILE: VerifyingTestCaller.cpp --- /** @file @brief Unit testcaller with verification $Id: VerifyingTestCaller.cpp,v 1.1 2005/12/10 19:23:45 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sun Jan 23 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. **/ #include <mockpp/mockpp.h> // always first #include <mockpp/VerifyingTestCaller.h> namespace mockpp { // is a template } // namespace mockpp --- NEW FILE: VerifyingTestCaller.h --- /** @file @brief Unit VerifyingTestCaller with verification $Id: VerifyingTestCaller.h,v 1.1 2005/12/10 19:23:45 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sun Jan 23 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_VerifyingTestCaller_H #define MOCKPP_VerifyingTestCaller_H #include <mockpp/mockpp.h> // always first #include <mockpp/MockObject.h> #include <mockpp/VerifyingTestCase.h> #ifdef HAVE_CPPUNIT #include <cppunit/TestCaller.h> namespace mockpp { /** VerifyingTestCaller that verifies Verifiable * fields and registered Verifiable objects after the test has run and before the fixture * has been torn down. * @ingroup grp_basic_mo * @ingroup grp_advanced_mo */ template <typename VerifyingFixtureType, bool DoTheVerify> class VerifyingTestCaller : public ::CppUnit::TestCaller<VerifyingFixtureType> { typedef void (VerifyingFixtureType::*TestCaseMethod)(); public: /** Constructor for VerifyingTestCaller. * This constructor does not create a new Fixture instance but accepts * an existing one as parameter. The VerifyingTestCaller will not own the * Fixture object. * \param name name of this VerifyingTestCaller * \param test the method this VerifyingTestCaller calls in runTest() * \param fixture the Fixture to invoke the test method on. */ VerifyingTestCaller(const std::string &name, TestCaseMethod test, VerifyingFixtureType& fixture) : ::CppUnit::TestCaller<VerifyingFixtureType>(name, test, fixture) , testcase(&fixture) { } /** Constructor for VerifyingTestCaller. * This constructor does not create a new Fixture instance but accepts * an existing one as parameter. The VerifyingTestCaller will own the * Fixture object and delete it in its destructor. * \param name name of this VerifyingTestCaller * \param test the method this VerifyingTestCaller calls in runTest() * \param fixture the Fixture to invoke the test method on. */ VerifyingTestCaller(const std::string &name, TestCaseMethod test, VerifyingFixtureType* fixture) : ::CppUnit::TestCaller<VerifyingFixtureType>(name, test, fixture) , testcase(fixture) { } /** Runs the test method with mock object verification afterwards. */ virtual void runTest() { testcase->unregisterVerifiables(); MOCKPP_TRY { ::CppUnit::TestCaller<VerifyingFixtureType>::runTest(); bool doVerify = DoTheVerify; if (doVerify) testcase->verify(); } #ifndef MOCKPP_NO_EXCEPTIONS catch(...) { testcase->unregisterVerifiables(); MOCKPP_RETHROW; } #endif testcase->unregisterVerifiables(); } /** Returns the the callers string representation. */ MOCKPP_STL::string toString() const { return "VerifyingTestCaller " + this->getName(); } private: VerifyingTestCase *testcase; VerifyingTestCaller( const VerifyingTestCaller &other ); VerifyingTestCaller &operator =( const VerifyingTestCaller &other ); }; } // namespace mockpp /** Add a method to the suite and verify after its run. * Substitutes CPPUNIT_TEST for cases where you wish to call \c verify() * automatically after test completion. * \param testMethod Name of the method of the test case to add to the * suite. The signature of the method must be of * type: void testMethod(); * \see CPPUNIT_TEST. */ #define MOCKPP_VERIFYING_TEST( testMethod ) \ CPPUNIT_TEST_SUITE_ADD_TEST( \ ( new mockpp::VerifyingTestCaller<TestFixtureType, true>( \ context.getTestNameFor( #testMethod), \ &TestFixtureType::testMethod, \ context.makeFixture() ) ) ) /** Add a method to the suite (but do NOT verify after its run). * Substitutes CPPUNIT_TEST. * \param testMethod Name of the method of the test case to add to the * suite. The signature of the method must be of * type: void testMethod(); * \see CPPUNIT_TEST. */ #define MOCKPP_TEST( testMethod ) \ CPPUNIT_TEST_SUITE_ADD_TEST( \ ( new mockpp::VerifyingTestCaller<TestFixtureType, false>( \ context.getTestNameFor( #testMethod), \ &TestFixtureType::testMethod, \ context.makeFixture() ) ) ) /** Add a test which verifies after its run and fails if the specified * exception is not caught. * Substitutes CPPUNIT_TEST_EXCEPTION for cases where you wish to call \c verify() * automatically after test completion. * \param testMethod Name of the method of the test case to add to the suite. * \param ExceptionType Type of the exception that must be thrown by the test * method. * \see CPPUNIT_TEST_EXCEPTION. * \deprecated Use one of the assertion macros like MOCKPP_ASSERT_THROWING instead. */ #define MOCKPP_VERIFYING_TEST_EXCEPTION( testMethod, ExceptionType ) \ CPPUNIT_TEST_SUITE_ADD_TEST( \ (new ::CppUnit::ExceptionTestCaseDecorator< ExceptionType >( \ new mockpp::VerifyingTestCaller< TestFixtureType, true >( \ context.getTestNameFor( #testMethod ), \ &TestFixtureType::testMethod, \ context.makeFixture() ) ) ) ) /** Add a test (which does NOT verify after its run) and fails if the specified * exception is not caught. * Substitutes CPPUNIT_TEST_EXCEPTION. * \param testMethod Name of the method of the test case to add to the suite. * \param ExceptionType Type of the exception that must be thrown by the test * method. * \see CPPUNIT_TEST_EXCEPTION. * \deprecated Use one of the assertion macros like MOCKPP_ASSERT_THROWING instead. */ #define MOCKPP_TEST_EXCEPTION( testMethod, ExceptionType ) \ CPPUNIT_TEST_SUITE_ADD_TEST( \ (new ::CppUnit::ExceptionTestCaseDecorator< ExceptionType >( \ new mockpp::VerifyingTestCaller< TestFixtureType, false >( \ context.getTestNameFor( #testMethod ), \ &TestFixtureType::testMethod, \ context.makeFixture() ) ) ) ) #endif // HAVE_CPPUNIT #endif // MOCKPP_VerifyingTestCaller_H --- NEW FILE: VerifyingTestCase.h --- /** @file @brief Unit testcase with verification $Id: VerifyingTestCase.h,v 1.1 2005/12/10 19:23:45 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. * * Original Java Sources: Copyright (c) 2000-2004, jMock.org * **/ #ifndef MOCKPP_VERIFYINGTESTCASE_H #define MOCKPP_VERIFYINGTESTCASE_H #include <mockpp/mockpp.h> // always first #include <mockpp/MockObject.h> #include <mockpp/util/AutoPointer.h> #ifdef HAVE_CPPUNIT #include <cppunit/TestCaller.h> namespace mockpp { /** TestCase that verifies Verifiable * fields and registered Verifiable objects after the test has run and before the fixture * has been torn down. * @ingroup grp_basic_mo * @ingroup grp_advanced_mo */ class VerifyingTestCase : public CppUnit::TestCase , public MockObject { public: /** Constructs the test case. */ VerifyingTestCase(); /** Constructs the test case. * @param name test case name */ VerifyingTestCase( const std::string &name ); /** Constructs the test case. */ virtual ~VerifyingTestCase(); /** Verifies the object and the mock objects it contains. * @attention Having no sub-objetcs to verify also counts as an error * because it is assumed that registration of the objects had been * forgotten. Otherwise there would be no reason to use this class. * If it fails, an AssertionFailedError is thrown */ virtual void verify(); /** Removes all verifiable fields from the list. */ virtual void unregisterVerifiables(); protected: /** Registers another verifiable object to the list. * @param verifiable pointer to the verifiable object */ void registerVerifiable(AutoPointer<Verifiable> verifiable); private: VerifyingTestCase (const VerifyingTestCase &); // forbid VerifyingTestCase& operator=(VerifyingTestCase&); MOCKPP_STL::vector<Verifiable*> registeredVerifiables; }; } // namespace mockpp #endif // MOCKPP_VerifyingTestCaller_H #endif // MOCKPP_VERIFYINGTESTCASE_H #include <mockpp/VerifyingTestCaller.h> --- NEW FILE: VerifyingTestCase.cpp --- /** @file @brief Unit testcase with verification $Id: VerifyingTestCase.cpp,v 1.1 2005/12/10 19:23:45 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. * * Original Java Sources: Copyright (c) 2000-2004, jMock.org * **/ #include <mockpp/mockpp.h> // always first #include <mockpp/VerifyingTestCase.h> #include <mockpp/compat/Exception.h> #include <mockpp/compat/Formatter.h> #include <mockpp/compat/AssertionFailedError.h> #ifdef HAVE_CPPUNIT #include <cppunit/Exception.h> #include <cppunit/SourceLine.h> #include <cppunit/TestResult.h> namespace mockpp { MOCKPP_EXPORT VerifyingTestCase::VerifyingTestCase() : CppUnit::TestCase() , MockObject(MOCKPP_PCHAR("VerifyingTestCase/*"), 0) { } MOCKPP_EXPORT VerifyingTestCase::VerifyingTestCase( const std::string &name) : CppUnit::TestCase(name) #ifdef MOCKPP_ALTERNATIVE_STL , MockObject(MOCKPP_PCHAR("VerifyingTestCase/")+MOCKPP_GET_STRING(name.c_str()), 0) #else , MockObject(MOCKPP_PCHAR("VerifyingTestCase/")+MOCKPP_GET_STRING(name), 0) #endif { } MOCKPP_EXPORT VerifyingTestCase::~VerifyingTestCase() { unregisterVerifiables(); } void MOCKPP_EXPORT VerifyingTestCase::verify() { if (numVerifiables() == 0) { String s = MOCKPP_PCHAR("VerifyingTestCase \"%1\" has no sub-objects to verify.\n") MOCKPP_PCHAR("Did you forget to register?"); s << getVerifiableName(); assertionFailed (__LINE__, __FILE__, s); } MockObject::verify(); } void MOCKPP_EXPORT VerifyingTestCase::registerVerifiable(AutoPointer<Verifiable> in_verifiable) { Verifiable *verifiable = in_verifiable.release(); registeredVerifiables.push_back(verifiable); if (!hasVerifiable(verifiable)) addVerifiable(verifiable); if (verifiable->getParent() == 0) verifiable->setParent(this); } void MOCKPP_EXPORT VerifyingTestCase::unregisterVerifiables() { clearVerifiables(); for (unsigned i = 0; i < registeredVerifiables.size(); ++i) delete registeredVerifiables[i]; registeredVerifiables.clear(); } } // namespace mockpp #endif // HAVE_CPPUNIT --- NEW FILE: SelectUnittestFramework.h --- /*************************************************************************** SelectUnittestFramework.h - setup for unittest framework in use ------------------- begin : Fri Dec 9 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de $Id: SelectUnittestFramework.h,v 1.1 2005/12/10 19:23:45 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** * * 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_SELECTUNITTESTFRAMEWORK_H #define MOCKPP_SELECTUNITTESTFRAMEWORK_H #if defined(HAVE_CXXTEST) # define MOCKPP_DERIVE_PUBLIC_UNITFRAMEWORK : public CxxTest::TestSuite #define CXXTEST_HAVE_STD #define CXXTEST_ABORT_TEST_ON_FAIL #ifndef CXXTEST_RUNNING #define CXXTEST_RUNNING #endif #define _CXXTEST_HAVE_STD #define _CXXTEST_HAVE_EH #include <cxxtest/TestListener.h> #include <cxxtest/TestTracker.h> #include <cxxtest/RealDescriptions.h> //#include <cxxtest/TestRunner.h> #include <mockpp/CxxTestSupport.h> #elif defined(HAVE_CPPUNIT) # include <cppunit/extensions/HelperMacros.h> # define MOCKPP_DERIVE_PUBLIC_UNITFRAMEWORK : public CppUnit::TestFixture #else # pragma message ("No unittest framework available at compile time") # define MOCKPP_DERIVE_PUBLIC_UNITFRAMEWORK /**/ #endif // frameworks #endif // MOCKPP_SELECTUNITTESTFRAMEWORK_H --- NEW FILE: CxxTestSupport.h --- /** @file @brief Support for CxxTest similar to CppUnit $Id: CxxTestSupport.h,v 1.1 2005/12/10 19:23:45 ewald-arnold Exp $ **************************************************************************/ /************************************************************************** begin : Fri Dec 9 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_CXXTEST_SUPPORT_H #define MOCKPP_CXXTEST_SUPPORT_H //////////////////////////////////////////////////////////////////////////// // #define MOCKPP_CXXTEST_SUITE_REGISTRATION(classname) \ static classname suite_ ## classname; \ \ static CxxTest::List tests_ ## classname = { 0, 0 }; \ \ CxxTest::StaticSuiteDescription suiteDescription_ ## classname( __FILE__, \ __LINE__, \ #classname, \ suite_ ## classname, \ tests_ ## classname) //////////////////////////////////////////////////////////////////////////// // #define MOCKPP_CXXTEST(classname, meth) \ static class TestDescription_ ## classname ## _ ## meth \ : public CxxTest::RealTestDescription { \ public: \ TestDescription_ ## classname ## _ ## meth() \ : CxxTest::RealTestDescription( tests_ ## classname, \ suiteDescription_ ##classname, \ __LINE__, \ #meth ) \ {} \ \ void runTest() \ { \ suite_ ## classname . meth(); \ } \ } testDescription_ ## classname ## _ ## meth //////////////////////////////////////////////////////////////////////////// // // #define MOCKPP_CXXTEST_SUITE_END #endif // MOCKPP_CXXTEST_SUPPORT_H |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:23:19
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32462/mockpp Removed Files: SelectUnittestFramework.h Log Message: moved to subdir framework --- SelectUnittestFramework.h DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:22:14
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32195/mockpp Removed Files: VerifyingTestCaller.cpp VerifyingTestCaller.h VerifyingTestCase.cpp VerifyingTestCase.h Log Message: moved to subdir framework --- VerifyingTestCase.cpp DELETED --- --- VerifyingTestCaller.cpp DELETED --- --- VerifyingTestCaller.h DELETED --- --- VerifyingTestCase.h DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:21:42
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32098/mockpp Removed Files: CxxTestSupport.h Log Message: moved to subdir framework --- CxxTestSupport.h DELETED --- |
Update of /cvsroot/mockpp/mockpp/mockpp/visiting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31785/mockpp/visiting Added Files: CountedVisitableMethod.h gen_countvisitable_N.pl gen_responsevector_N.pl gen_visitablemethod_N.pl ResponseVector1.h ResponseVector2.h ResponseVector3.h ResponseVector4.h ResponseVector5.h ResponseVector6.h VisitableMockMethod0.h VisitableMockMethod1.h VisitableMockMethod2.h VisitableMockMethod3.h VisitableMockMethod4.h VisitableMockMethod5.h VisitableMockMethod6.h VisitableMockMethod.cpp VisitableMockMethod.h VisitableMockObject.cpp VisitableMockObject.h VisitableMockObject_macro.h VisitableMockObject_template.h Log Message: moved to subdir visiting --- 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/12/10 19:20:00 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. */ void reset() { counter.clear(); tvec.reset(); 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: MOCKPP_STL::vector<Constraint<P1>*> t1vec; MOCKPP_STL::vector<Constraint<P2>*> t2vec; MOCKPP_STL::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. */ void reset() { ResponseThrowableVector3<P1, P2, P3>::reset(); 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: MOCKPP_STL::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector3_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/12/10 19:20:00 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. */ void reset() { counter.clear(); tvec.reset(); 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: MOCKPP_STL::vector<Constraint<P1>*> t1vec; MOCKPP_STL::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. */ void reset() { ResponseThrowableVector2<P1, P2>::reset(); 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: MOCKPP_STL::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector2_H --- NEW FILE: VisitableMockObject_macro.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION, USE @p VisitableMockObject.h INSTEAD @brief Keep ugly macros away from header files $Id: VisitableMockObject_macro.h,v 1.1 2005/12/10 19:20:00 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Fri Feb 07 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. [...1393 lines suppressed...] addExpectedMethod(mockpp::getLatin1(getVerifiableName()) + "." + #m_name); \ m_name ## Parameter1.addExpected(param1); \ m_name ## Parameter2.addExpected(param2); \ m_name ## Parameter3.addExpected(param3); \ m_name ## Parameter4.addExpected(param4); \ m_name ## Parameter5.addExpected(param5); \ return v_ret_type(); \ } \ MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \ MOCKPP_DECLARE_DEFAULT_VARS(m_name); \ MOCKPP_DECLARE_RETURN_VARS(v_ret_type, m_name); \ mutable mockpp::ResponseVector5< v_ret_type, v_type1, v_type2, v_type3, v_type4, v_type5 > m_name ## ResponseValues; \ MOCKPP_DECLARE_PARAMETER_VARS5(m_name, v_type1, v_type2, v_type3, v_type4, v_type5); \ MOCKPP_CONTROLLER_DECL5(classname, v_ret_type, m_name, v_type1, v_type2, v_type3, v_type4, v_type5) #endif // DOXYGEN_SHOULD_SKIP_THIS #endif // MOCKPP_VISITABLEMOCKOBJECT_MACRO_H --- NEW FILE: VisitableMockObject.cpp --- /** @file @brief MockObjects that can be visited under control $Id: VisitableMockObject.cpp,v 1.1 2005/12/10 19:20:00 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Fri Dec 18 2002 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. **/ #include <mockpp/mockpp.h> // always first #include <mockpp/VisitableMockObject.h> namespace mockpp { MOCKPP_EXPORT VisitableMockObjectBase::VisitableMockObjectBase(const String &name, VerifiableList *parent) :methodList(name+MOCKPP_PCSTRING("/methodList"), parent) { activated = false; } MOCKPP_EXPORT VisitableMockObjectBase::~VisitableMockObjectBase() { } void MOCKPP_EXPORT VisitableMockObjectBase::addExpectedMethod(const MOCKPP_STL::string &name) const { MOCKPP_ASSERT_EQUALS(isActivated(), false); methodList.addExpected(name); } void MOCKPP_EXPORT VisitableMockObjectBase::addActualMethod(const MOCKPP_STL::string &name) const { MOCKPP_ASSERT_EQUALS(isActivated(), true); methodList.addActual(name); } void MOCKPP_EXPORT VisitableMockObjectBase::activate() { activated = true; } bool MOCKPP_EXPORT VisitableMockObjectBase::isActivated() const { return activated; } void MOCKPP_EXPORT VisitableMockObjectBase::visitableVerify() { methodList.verify(); for (unsigned i = 0; i < controllers.size(); ++i) controllers[i]->verify(); } void MOCKPP_EXPORT VisitableMockObjectBase::visitableReset() { activated = false; for (unsigned i = 0; i < controllers.size(); ++i) controllers[i]->reset(); } void MOCKPP_EXPORT VisitableMockObjectBase::unsetThrowablesInline() { for (unsigned i = 0; i < controllers.size(); ++i) controllers[i]->unsetThrowablesInline(); } void MOCKPP_EXPORT VisitableMockObjectBase::addController (Controller *ctr) { controllers.push_back(ctr); } void MOCKPP_EXPORT VisitableMockObjectBase::removeController (Controller *ctr) { MOCKPP_STL::vector<Controller*>::iterator it = MOCKPP_STL::find (controllers.begin(), controllers.end(), ctr); if (it != controllers.end()) controllers.erase(it); } unsigned MOCKPP_EXPORT VisitableMockObjectBase::numController() const { return controllers.size(); } ///////////////////////////////////////////////////////////////// MOCKPP_EXPORT VisitableMockObject::VisitableMockObject(const String &name, VerifiableList *parent) : MockObject(name, parent) , VisitableMockObjectBase(name, this) { } MOCKPP_EXPORT VisitableMockObject::~VisitableMockObject() { } void MOCKPP_EXPORT VisitableMockObject::verify() { MockObject::verify(); visitableVerify(); } void MOCKPP_EXPORT VisitableMockObject::reset() { MockObject::reset(); visitableReset(); } ///////////////////////////////////////////////////////////////// MOCKPP_EXPORT VisitableMockObject::Controller::~Controller() { } } // namespace mockpp --- NEW FILE: CountedVisitableMethod.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_countvisitable.pl. $Id: CountedVisitableMethod.h,v 1.1 2005/12/10 19:19:59 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sun Oct 30 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_COUNTEDVISITABLEMETHOD_H #define MOCKPP_COUNTEDVISITABLEMETHOD_H #include <mockpp/CountParameters.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/VisitableMockMethod6.h> namespace mockpp { #ifndef MOCKPP_COUNTED_WEAKNESS /** Helper class to select the method mock with the correct number of parameters. * Works with meta programming. * @internal */ template<unsigned params> class SwitchVisitable { }; /** Helper class to select the method mock with 0 parameters. * Works with meta programming. * @internal */ template<> class SwitchVisitable<0> { public: /** Helper class with an embeded type to the the method mock with 0 parameters. */ template< typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6> class Method { public: typedef VisitableMockMethod0<R> VisitableMockMethodType; }; }; /** Helper class to select the method mock with 1 parameters. * Works with meta programming. * @internal */ template<> class SwitchVisitable<1> { public: /** Helper class with an embeded type to the the method mock with 1 parameters. */ template< typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6> class Method { public: typedef VisitableMockMethod1<R, P1> VisitableMockMethodType; }; }; /** Helper class to select the method mock with 2 parameters. * Works with meta programming. * @internal */ template<> class SwitchVisitable<2> { public: /** Helper class with an embeded type to the the method mock with 2 parameters. */ template< typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6> class Method { public: typedef VisitableMockMethod2<R, P1, P2> VisitableMockMethodType; }; }; /** Helper class to select the method mock with 3 parameters. * Works with meta programming. * @internal */ template<> class SwitchVisitable<3> { public: /** Helper class with an embeded type to the the method mock with 3 parameters. */ template< typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6> class Method { public: typedef VisitableMockMethod3<R, P1, P2, P3> VisitableMockMethodType; }; }; /** Helper class to select the method mock with 4 parameters. * Works with meta programming. * @internal */ template<> class SwitchVisitable<4> { public: /** Helper class with an embeded type to the the method mock with 4 parameters. */ template< typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6> class Method { public: typedef VisitableMockMethod4<R, P1, P2, P3, P4> VisitableMockMethodType; }; }; /** Helper class to select the method mock with 5 parameters. * Works with meta programming. * @internal */ template<> class SwitchVisitable<5> { public: /** Helper class with an embeded type to the the method mock with 5 parameters. */ template< typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6> class Method { public: typedef VisitableMockMethod5<R, P1, P2, P3, P4, P5> VisitableMockMethodType; }; }; /** Helper class to select the method mock with 6 parameters. * Works with meta programming. * @internal */ template<> class SwitchVisitable<6> { public: /** Helper class with an embeded type to the the method mock with 6 parameters. */ template< typename R , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6> class Method { public: typedef VisitableMockMethod6<R, P1, P2, P3, P4, P5, P6> VisitableMockMethodType; }; }; /** Method mock class to select the actual class with the desired number of parameters. * Works with meta programming. */ template< typename R , typename P1 = NoParameter , typename P2 = NoParameter , typename P3 = NoParameter , typename P4 = NoParameter , typename P5 = NoParameter , typename P6 = NoParameter> class VisitableMockMethod : public SwitchVisitable<CountParameters<R, P1, P2, P3, P4, P5, P6>::value> ::template Method<R, P1, P2, P3, P4, P5, P6> ::VisitableMockMethodType { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ VisitableMockMethod(const String &name, VisitableMockObject *parent ) : SwitchVisitable<CountParameters<R, P1, P2, P3, P4, P5, P6>::value > ::template Method<R, P1, P2, P3, P4, P5, P6> ::VisitableMockMethodType(name, parent) { } }; #else // MOCKPP_COUNTED_WEAKNESS /** Helper class to select the method mock with the correct number of parameters. * Works with partial specialisation. * @internal */ template< typename R , typename P1 = NoParameter , typename P2 = NoParameter , typename P3 = NoParameter , typename P4 = NoParameter , typename P5 = NoParameter , typename P6 = NoParameter , typename P7 = NoParameter> class VisitableMockMethod { }; /** Method mock class to select the actual class with 0 parameters. * Works with partial specialisation. */ template<typename R> class VisitableMockMethod<R, NoParameter, NoParameter, NoParameter, NoParameter, NoParameter, NoParameter> : public VisitableMockMethod0<R> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ VisitableMockMethod<R, NoParameter, NoParameter, NoParameter, NoParameter, NoParameter, NoParameter> (const String &name, VisitableMockObject *parent ) : VisitableMockMethod0<R>(name, parent) { } }; /** Method mock class to select the actual class with 1 parameters. * Works with partial specialisation. */ template<typename R, typename P1> class VisitableMockMethod<R, P1, NoParameter, NoParameter, NoParameter, NoParameter, NoParameter> : public VisitableMockMethod1<R, P1> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ VisitableMockMethod<R, P1, NoParameter, NoParameter, NoParameter, NoParameter, NoParameter> (const String &name, VisitableMockObject *parent ) : VisitableMockMethod1<R, P1>(name, parent) { } }; /** Method mock class to select the actual class with 2 parameters. * Works with partial specialisation. */ template<typename R, typename P1, typename P2> class VisitableMockMethod<R, P1, P2, NoParameter, NoParameter, NoParameter, NoParameter> : public VisitableMockMethod2<R, P1, P2> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ VisitableMockMethod<R, P1, P2, NoParameter, NoParameter, NoParameter, NoParameter> (const String &name, VisitableMockObject *parent ) : VisitableMockMethod2<R, P1, P2>(name, parent) { } }; /** Method mock class to select the actual class with 3 parameters. * Works with partial specialisation. */ template<typename R, typename P1, typename P2, typename P3> class VisitableMockMethod<R, P1, P2, P3, NoParameter, NoParameter, NoParameter> : public VisitableMockMethod3<R, P1, P2, P3> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ VisitableMockMethod<R, P1, P2, P3, NoParameter, NoParameter, NoParameter> (const String &name, VisitableMockObject *parent ) : VisitableMockMethod3<R, P1, P2, P3>(name, parent) { } }; /** Method mock class to select the actual class with 4 parameters. * Works with partial specialisation. */ template<typename R, typename P1, typename P2, typename P3, typename P4> class VisitableMockMethod<R, P1, P2, P3, P4, NoParameter, NoParameter> : public VisitableMockMethod4<R, P1, P2, P3, P4> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ VisitableMockMethod<R, P1, P2, P3, P4, NoParameter, NoParameter> (const String &name, VisitableMockObject *parent ) : VisitableMockMethod4<R, P1, P2, P3, P4>(name, parent) { } }; /** Method mock class to select the actual class with 5 parameters. * Works with partial specialisation. */ template<typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class VisitableMockMethod<R, P1, P2, P3, P4, P5, NoParameter> : public VisitableMockMethod5<R, P1, P2, P3, P4, P5> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ VisitableMockMethod<R, P1, P2, P3, P4, P5, NoParameter> (const String &name, VisitableMockObject *parent ) : VisitableMockMethod5<R, P1, P2, P3, P4, P5>(name, parent) { } }; /** Method mock class to select the actual class with 6 parameters. * Works with partial specialisation. */ template<typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> class VisitableMockMethod<R, P1, P2, P3, P4, P5, P6> : public VisitableMockMethod6<R, P1, P2, P3, P4, P5, P6> { public: /** Constructs the mock object. * @param name human readable description about the expectation * @param parent parent chainable mock object */ VisitableMockMethod<R, P1, P2, P3, P4, P5, P6> (const String &name, VisitableMockObject *parent ) : VisitableMockMethod6<R, P1, P2, P3, P4, P5, P6>(name, parent) { } }; #endif // MOCKPP_COUNTED_WEAKNESS } // ns mockpp #endif // MOCKPP_COUNTEDVISITABLEMETHOD_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/12/10 19:20:00 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 or setup expectations. * @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->responseThrowables.find(t, p1, p2, p3, p4)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); parameter3.balanceActual(); parameter4.balanceActual(); MOCKPP_RETHROW; } parameter1.addActual(p1); parameter2.addActual(p2); parameter3.addActual(p3); parameter4.addActual(p4); } } public: /** 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->getVisitableMockObject()->isActivated()); this->responseThrowables.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->getVisitableMockObject()->isActivated()); this->responseThrowables.add(t, p1, p2, p3, p4, count); } 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); if (this->getVisitableMockObject()->isActivated() ) { R ret_val; if (this->responseValues.find(ret_val, p1, p2, p3, p4)) return ret_val; return this->determineReturnValue(); } else return R(); // only dummy value to make the compiler happy } #if defined(__BORLANDC__) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 /** 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 { VisitableMockMethod4Common<R, P1, P2, P3, P4>::forward(p1, p2, p3, p4); } #else using VisitableMockMethod4Common<R, P1, P2, P3, P4>::forward; #endif /** 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->getVisitableMockObject()->isActivated()); this->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->getVisitableMockObject()->isActivated()); this->responseValues.add(rv, p1, p2, p3, p4, count); } 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); } #if defined(__BORLANDC__) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 /** 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 { VisitableMockMethod4Common<void, P1, P2, P3, P4>::forward(p1, p2, p3, p4); } #else using VisitableMockMethod4Common<void, P1, P2, P3, P4>::forward; #endif }; } // ns mockpp #endif // MOCKPP_VisitableMockMethod4_H --- NEW FILE: gen_countvisitable_N.pl --- #!/usr/bin/perl -w # # $Id: gen_countvisitable_N.pl,v 1.1 2005/12/10 19:19:59 ewald-arnold Exp $ use English; if ($#ARGV < 0) { print "Usage: perl gen_countvisitable <number of arguments>\n"; exit; } $totalNumArgs = $ARGV[0]; if ($totalNumArgs < 5) { $totalNumArgs = 5; } for ($numArgs = 1; $numArgs <= $totalNumArgs; ++$numArgs) { } open OUT, ">CountedVisitableMethod.h"; print OUT "/** \@file \@internal NOT INTENDED FOR PUBLIC INCLUSION \@brief Generated with gen_countvisitable.pl. \$I" . "d: CountedVisitableMethod.h,v 1.7 2005/10/19 20:53:09 ewald-arnold Exp \$ ***************************************************************************/ /************************************************************************** begin : Sun Oct 30 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_COUNTEDVISITABLEMETHOD_H #define MOCKPP_COUNTEDVISITABLEMETHOD_H #include <mockpp/CountParameters.h> "; for ($p = 0; $p <= $totalNumArgs; ++$p) { print OUT " #include <mockpp/VisitableMockMethod" . $p . ".h>";} print OUT " namespace mockpp { #ifndef MOCKPP_COUNTED_WEAKNESS /** Helper class to select the method mock with the correct number of parameters. * Works with meta programming. * \@internal */ template<unsigned params> class SwitchVisitable { }; "; for ($numArgs = 0; $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; } print "Creating CountedVisitableMethod" . $numArgs ."\n"; print OUT " /** Helper class to select the method mock with " . $numArgs ." parameters. * Works with meta programming. * \@internal */ template<> class SwitchVisitable<" . $numArgs ."> { public: "; print OUT " /** Helper class with an embeded type to the the method mock with " . $numArgs ." parameters. */ template< typename R"; for($p = 1; $p <= $totalNumArgs; ++$p) { print OUT " , typename P" . $p; } print OUT "> class Method { public: typedef VisitableMockMethod" . $numArgs ."<R" . $templateArgs_colon . "> VisitableMockMethodType; }; }; "; } print OUT " /** Method mock class to select the actual class with the desired number of parameters. * Works with meta programming. */ template< typename R , typename P1 = NoParameter"; for($p = 2; $p <= $totalNumArgs; ++$p) { print OUT " , typename P" . $p . " = NoParameter"; }; print OUT "> class VisitableMockMethod : public SwitchVisitable<CountParameters<R, " . $templateArgs . ">::value> ::template Method<R, " . $templateArgs . "> ::VisitableMockMethodType { public: /** Constructs the mock object. * \@param name human readable description about the expectation * \@param parent parent chainable mock object */ VisitableMockMethod(const String &name, VisitableMockObject *parent ) : SwitchVisitable<CountParameters<R, " . $templateArgs . ">::value > ::template Method<R, " . $templateArgs . "> ::VisitableMockMethodType(name, parent) { } }; #else // MOCKPP_COUNTED_WEAKNESS /** Helper class to select the method mock with the correct number of parameters. * Works with partial specialisation. * \@internal */ template< typename R , typename P1 = NoParameter"; for($p = 2; $p <= $totalNumArgs+1; ++$p) { print OUT " , typename P" . $p . " = NoParameter"; }; print OUT "> class VisitableMockMethod { }; "; for ($numArgs = 0; $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; } $noParamArgs = $templateArgs; for ($i = $numArgs+1; $i <= $totalNumArgs; ++$i) { if ($i > 1) { $noParamArgs .= ", "; } $noParamArgs .= "NoParameter"; } print OUT " /** Method mock class to select the actual class with " . $numArgs . " parameters. * Works with partial specialisation. */ template<typename R" . $templateParms_colon . "> class VisitableMockMethod<R, " . $noParamArgs . "> : public VisitableMockMethod" . $numArgs . "<R" . $templateArgs_colon . "> { public: /** Constructs the mock object. * \@param name human readable description about the expectation * \@param parent parent chainable mock object */ VisitableMockMethod<R, " . $noParamArgs . "> (const String &name, VisitableMockObject *parent ) : VisitableMockMethod" . $numArgs . "<R" . $templateArgs_colon . ">(name, parent) { } }; "; } print OUT " #endif // MOCKPP_COUNTED_WEAKNESS } // ns mockpp #endif // MOCKPP_COUNTEDVISITABLEMETHOD_H "; close OUT; --- 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/12/10 19:20:00 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 or setup expectations. * @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->responseThrowables.find(t, p1, p2, p3, p4, p5)) t->throw_me(); this->throwAvailableException(); } catch(...) { parameter1.balanceActual(); parameter2.balanceActual(); parameter3.balanceActual(); parameter4.balanceActual(); parameter5.balanceActual(); MOCKPP_RETHROW; } parameter1.addActual(p1); parameter2.addActual(p2); parameter3.addActual(p3); parameter4.addActual(p4); parameter5.addActual(p5); } } public: /** 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->getVisitableMockObject()->isActivated()); this->responseThrowables.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->getVisitableMockObject()->isActivated()); this->responseThrowables.add(t, p1, p2, p3, p4, p5, count); } private: mutable ResponseThrowableVector5<P1, P2, P3, P4, P5> responseThrowables; mutable ConstraintList<P1> parameter1; mutable ConstraintList<P2> parameter2; mutable ConstraintList<P3> ... [truncated message content] |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:19:27
|
Update of /cvsroot/mockpp/mockpp/mockpp/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31708/mockpp/framework Added Files: .cvsignore Makefile.am Log Message: new --- NEW FILE: .cvsignore --- --- NEW FILE: Makefile.am --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:18:58
|
Update of /cvsroot/mockpp/mockpp/mockpp/chaining In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31638/mockpp/chaining Added Files: ChainableMockObject.cpp ChainableMockObject.h Log Message: moved to subdir chaining --- NEW FILE: ChainableMockObject.cpp --- /** @file @brief MockObjects with chained setup parameters $Id: ChainableMockObject.cpp,v 1.1 2005/12/10 19:18:50 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Sep 28 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. **/ #include <mockpp/mockpp.h> // always first #include MOCKPP_ALGORITHM_H #include <mockpp/ChainableMockObject.h> namespace mockpp { MOCKPP_EXPORT ChainableMockObjectBase::ChainableMockObjectBase(const String &name) : BuilderNamespace(name) { } MOCKPP_EXPORT ChainableMockObjectBase::~ChainableMockObjectBase() { chainableReset(); } void MOCKPP_EXPORT ChainableMockObjectBase::chainableVerify() { checkPendingRecorders(); } void MOCKPP_EXPORT ChainableMockObjectBase::checkPendingRecorders() const { String penders; while(pendingRecorders.size() != 0) { if (penders.length() != 0) penders += MOCKPP_PCHAR(", "); penders += (*pendingRecorders.begin()).first; delete (*pendingRecorders.begin()).second; pendingRecorders.erase(pendingRecorders.begin()); } if (penders.length() != 0) assertionFailed( __LINE__, __FILE__, MOCKPP_PCHAR("Chaining mock object \"") + getIdent() + MOCKPP_PCHAR( "\": there are unassigned idenfiers:\n " ) + penders); } MatchBuilderAdapterBase * MOCKPP_EXPORT ChainableMockObjectBase::lookupID( const String &id ) const { TableType::const_iterator it = idTable.find( id ); if ( it == idTable.end() ) return 0; return ( (*it).second ); } void MOCKPP_EXPORT ChainableMockObjectBase::registerUniqueID( const String &id, MatchBuilderAdapterBase *builder ) { MatchBuilderAdapterBase *tmb = lookupID(id); if ( tmb != 0 ) assertionFailed( __LINE__, __FILE__, MOCKPP_PCHAR( "duplicate invocation named \"" ) + id + MOCKPP_PCHAR( "\"" ) ); storeID(id, builder); } void MOCKPP_EXPORT ChainableMockObjectBase::storeBuilder( AutoPointer<MatchBuilderAdapterBase> builder ) { allBuilders.push_back(builder.release()); } void MOCKPP_EXPORT ChainableMockObjectBase::addPendingRecorder(const String &id, InvokedRecorder::AP recorder) { pendingRecorders.insert( MOCKPP_STL::make_pair(id, recorder.release()) ); } void MOCKPP_EXPORT ChainableMockObjectBase::storeID( const String &id, MatchBuilderAdapterBase *builder ) { idTable.insert( MOCKPP_STL::make_pair(id, builder) ); PendingType::iterator it; while ( (it = pendingRecorders.find( id )) != pendingRecorders.end() ) { builder->match( (*it).second ); pendingRecorders.erase(it); } } void MOCKPP_EXPORT ChainableMockObjectBase::chainableReset() { while(idTable.size() != 0) { delete (*idTable.begin()).second; idTable.erase(idTable.begin()); } for (unsigned i = 0; i < allBuilders.size(); ++i) delete allBuilders[i]; allBuilders.clear(); while(pendingRecorders.size() != 0) { delete (*pendingRecorders.begin()).second; pendingRecorders.erase(pendingRecorders.begin()); } } ///////////////////////////////////////////////////////////////// MOCKPP_EXPORT ChainableMockObject::ChainableMockObject(const String &name, VerifiableList *parent) : MockObject(name, parent) , ChainableMockObjectBase(name) { } MOCKPP_EXPORT ChainableMockObject::~ChainableMockObject() { reset(); } void MOCKPP_EXPORT ChainableMockObject::verify() { MockObject::verify(); chainableVerify(); } void MOCKPP_EXPORT ChainableMockObject::reset() { MockObject::reset(); chainableReset(); } } // namespace mockpp --- NEW FILE: ChainableMockObject.h --- /** @file @brief MockObjects that can be chained under control. $Id: ChainableMockObject.h,v 1.1 2005/12/10 19:18:50 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Thu Sep 28 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, [...1218 lines suppressed...] /** Implements the initializers for the internal variables of a * method with 5 parameters. * @param name the method name */ #define MOCKPP_CONSTRUCT_MEMBERS_FOR_CHAINABLE5(name) \ MOCKPP_CONSTRUCT_CHAINABLE_MEMBERS(name) /** Implements the initializers for the internal variables of a * method with 5 parameters. * @param m_name the method name * @param x_name extension for internal naming */ #define MOCKPP_CONSTRUCT_MEMBERS_FOR_CHAINABLE_EXT5(m_name, x_name) \ MOCKPP_CONSTRUCT_MEMBERS_FOR_CHAINABLE5(m_name ## x_name) #endif // MOCKPP_CHAINABLEMOCKOBJECT_H |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:15:03
|
Update of /cvsroot/mockpp/mockpp/mockpp/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31039/mockpp/framework Log Message: Directory /cvsroot/mockpp/mockpp/mockpp/framework added to the repository |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:14:46
|
Update of /cvsroot/mockpp/mockpp/mockpp/visiting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30986/mockpp/visiting Added Files: .cvsignore Makefile.am Log Message: new --- NEW FILE: .cvsignore --- --- NEW FILE: Makefile.am --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:14:09
|
Update of /cvsroot/mockpp/mockpp/mockpp/visiting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30850/mockpp/visiting Log Message: Directory /cvsroot/mockpp/mockpp/mockpp/visiting added to the repository |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:13:53
|
Update of /cvsroot/mockpp/mockpp/mockpp/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30807/mockpp/config Added Files: .cvsignore Makefile.am Log Message: new --- NEW FILE: .cvsignore --- --- NEW FILE: Makefile.am --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:13:31
|
Update of /cvsroot/mockpp/mockpp/mockpp/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30774/mockpp/config Log Message: Directory /cvsroot/mockpp/mockpp/mockpp/config added to the repository |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:12:49
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30660/mockpp Removed Files: gen_countvisitable_N.pl gen_responsevector_N.pl gen_visitablemethod_N.pl Log Message: moved to subdir visiting --- gen_responsevector_N.pl DELETED --- --- gen_visitablemethod_N.pl DELETED --- --- gen_countvisitable_N.pl DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:12:24
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30505/mockpp Removed Files: ResponseVector1.h ResponseVector2.h ResponseVector3.h ResponseVector4.h ResponseVector5.h ResponseVector6.h Log Message: moved to subdir visiting --- ResponseVector3.h DELETED --- --- ResponseVector2.h DELETED --- --- ResponseVector4.h DELETED --- --- ResponseVector1.h DELETED --- --- ResponseVector5.h DELETED --- --- ResponseVector6.h DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:11:38
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30218/mockpp Removed Files: ChainableMockObject.cpp ChainableMockObject.h Log Message: moved to subdir chaining --- ChainableMockObject.cpp DELETED --- --- ChainableMockObject.h DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 19:09:35
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29580/mockpp Removed Files: CountedVisitableMethod.h Log Message: moved to subdir visiting --- CountedVisitableMethod.h DELETED --- |
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28487/mockpp Removed Files: VisitableMockMethod0.h VisitableMockMethod1.h VisitableMockMethod2.h VisitableMockMethod3.h VisitableMockMethod4.h VisitableMockMethod5.h VisitableMockMethod6.h VisitableMockMethod.cpp VisitableMockMethod.h VisitableMockObject.cpp VisitableMockObject.h VisitableMockObject_macro.h VisitableMockObject_template.h Log Message: moved to subdir visiting --- VisitableMockMethod1.h DELETED --- --- VisitableMockMethod.cpp DELETED --- --- VisitableMockMethod6.h DELETED --- --- VisitableMockObject_macro.h DELETED --- --- VisitableMockMethod2.h DELETED --- --- VisitableMockObject_template.h DELETED --- --- VisitableMockObject.cpp DELETED --- --- VisitableMockMethod3.h DELETED --- --- VisitableMockMethod.h DELETED --- --- VisitableMockMethod4.h DELETED --- --- VisitableMockMethod0.h DELETED --- --- VisitableMockMethod5.h DELETED --- --- VisitableMockObject.h DELETED --- |
Update of /cvsroot/mockpp/mockpp/bcb6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26094/bcb6 Removed Files: .cvsignore Makefile.am basicmock.bpf basicmock.bpr chainmock.bpf chainmock.bpr cppunit.bpf cppunit.bpr gen-mak.bat jmock_test.bpf jmock_test.bpr mock_greeter.bpf mock_greeter.bpr mock_test.bpf mock_test.bpr mockpp.bpf mockpp.bpg mockpp.bpr mockpp_production.bpf mockpp_production.bpr poormock-se.bpf poormock-se.bpr poormock.bpf poormock.bpr readability.bpf readability.bpr verifying.bpf verifying.bpr visitmock.bpf visitmock.bpr Log Message: remove not supported stuff --- .cvsignore DELETED --- --- mock_greeter.bpr DELETED --- --- mock_greeter.bpf DELETED --- --- mock_test.bpf DELETED --- --- mock_test.bpr DELETED --- --- jmock_test.bpf DELETED --- --- visitmock.bpr DELETED --- --- cppunit.bpf DELETED --- --- readability.bpf DELETED --- --- visitmock.bpf DELETED --- --- Makefile.am DELETED --- --- jmock_test.bpr DELETED --- --- readability.bpr DELETED --- --- cppunit.bpr DELETED --- --- poormock.bpr DELETED --- --- verifying.bpr DELETED --- --- mockpp_production.bpf DELETED --- --- poormock.bpf DELETED --- --- verifying.bpf DELETED --- --- mockpp_production.bpr DELETED --- --- chainmock.bpf DELETED --- --- poormock-se.bpr DELETED --- --- basicmock.bpr DELETED --- --- mockpp.bpr DELETED --- --- poormock-se.bpf DELETED --- --- basicmock.bpf DELETED --- --- gen-mak.bat DELETED --- --- chainmock.bpr DELETED --- --- mockpp.bpf DELETED --- --- mockpp.bpg DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 18:46:38
|
Update of /cvsroot/mockpp/mockpp/bcbX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24113/bcbX Removed Files: !README .cvsignore Makefile.am basicmock.cbx chainmock.cbx cppunit.cbx jmock_test.cbx mock_greeter.cbx mock_test.cbx mockpp.bpgr mockpp.cbx poormock-se.cbx poormock.cbx verifying.cbx visitmock.cbx Log Message: cleanup old stuff --- .cvsignore DELETED --- --- cppunit.cbx DELETED --- --- mockpp.cbx DELETED --- --- mockpp.bpgr DELETED --- --- visitmock.cbx DELETED --- --- poormock-se.cbx DELETED --- --- mock_greeter.cbx DELETED --- --- chainmock.cbx DELETED --- --- poormock.cbx DELETED --- --- jmock_test.cbx DELETED --- --- mock_test.cbx DELETED --- --- !README DELETED --- --- Makefile.am DELETED --- --- basicmock.cbx DELETED --- --- verifying.cbx DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 18:46:38
|
Update of /cvsroot/mockpp/mockpp/bcbX/cppunit-lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24113/bcbX/cppunit-lib Removed Files: .cvsignore Makefile.am README.txt cppunit_1_10.cbx Log Message: cleanup old stuff --- cppunit_1_10.cbx DELETED --- --- .cvsignore DELETED --- --- Makefile.am DELETED --- --- README.txt DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 18:45:17
|
Update of /cvsroot/mockpp/mockpp/msvc6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23849/msvc6 Removed Files: .cvsignore Makefile.am Log Message: cleanup old stuff --- .cvsignore DELETED --- --- Makefile.am DELETED --- |
From: Ewald A. <ewa...@us...> - 2005-12-10 18:45:17
|
Update of /cvsroot/mockpp/mockpp/msvc6/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23849/msvc6/mockpp Removed Files: .cvsignore Makefile.am mockpp.dsp mockpp.dsw Log Message: cleanup old stuff --- mockpp.dsw DELETED --- --- .cvsignore DELETED --- --- Makefile.am DELETED --- --- mockpp.dsp DELETED --- |