Thread: [Mockpp-commits] mockpp/mockpp/tests ChainableMockMethod_2_test.cpp,NONE,1.1 VisitableMockMethod_1_t
Brought to you by:
ewald-arnold
Update of /cvsroot/mockpp/mockpp/mockpp/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27415/mockpp/tests Modified Files: ChainableMockMethod_1_test.cpp Makefile.am Added Files: ChainableMockMethod_2_test.cpp VisitableMockMethod_1_test.cpp VisitableMockMethod_2_test.cpp Log Message: new files --- NEW FILE: VisitableMockMethod_2_test.cpp --- /*************************************************************************** VisitableMockMethod_2_test.cpp - unit tests for VisitableMockObject class and 1 parameter methods ------------------- begin : Thu Oct 2 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de $Id: VisitableMockMethod_2_test.cpp,v 1.1 2005/10/02 18:51:33 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. * ***************************************************************************/ #include <mockpp/mockpp.h> // always first #ifndef HAVE_CPPUNIT # warning CppUnit not available at compile time #else #include <mockpp/VisitableMockMethod.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/constraint/OutBound.h> #include <cppunit/extensions/HelperMacros.h> namespace { // anon class VisitableMockMethod_2_test : public CppUnit::TestFixture { public: CPPUNIT_TEST_SUITE( VisitableMockMethod_2_test ); CPPUNIT_TEST( test_parameter_2 ); CPPUNIT_TEST_SUITE_END(); public: void test_parameter_2(); }; CPPUNIT_TEST_SUITE_REGISTRATION(VisitableMockMethod_2_test); class MyVisitableMockObject_2 : public mockpp::VisitableMockObject { public: MyVisitableMockObject_2(const mockpp::String &name) : mockpp::VisitableMockObject(name, 0) , visitable_mocker(MOCKPP_PCHAR("Visitable"), this) {} int visitable(unsigned i) { return visitable_mocker.forward(i); } mockpp::VisitableMockMethod1<int, unsigned> visitable_mocker; }; void VisitableMockMethod_2_test::test_parameter_2() { MyVisitableMockObject_2 mcm(MOCKPP_PCHAR("Visitable-object")); /* mockpp::VisitableMockMethod2<int, unsigned>::ChainerFor chain(mcm, mcm.Visitable_mocker); CPPUNIT_ASSERT(mcm.Visitable(12) == 21); CPPUNIT_ASSERT(mcm.Visitable(34) == 43); try { mcm.Visitable(56); CPPUNIT_ASSERT_MESSAGE("should have thrown", false); } catch(mockpp::AssertionFailedError &ex) { CPPUNIT_ASSERT(ex.getMessage().find(MOCKPP_PCHAR("unexpected invocation")) != mockpp::String::npos); } */ mcm.verify(); } } // anon ns #endif // HAVE_CPPUNIT Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/Makefile.am,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- Makefile.am 2 Oct 2005 10:56:15 -0000 1.82 +++ Makefile.am 2 Oct 2005 18:51:33 -0000 1.83 @@ -42,41 +42,42 @@ ########################################################################### mock_test_SOURCES = mock_test.cpp VisitableMockObject_test.cpp \ - Formatter_test.cpp Throwable_test.cpp ThrowableList_test.cpp ExpectationCounter_test.cpp \ - ExpectationCounterRange_test.cpp ExpectationMap_test.cpp ExpectationList_test.cpp \ - ConstraintList_test.cpp ExpectationSet_test.cpp ExpectationConglomeration_test.cpp \ - ExpectationSegment_test.cpp ExpectationValue_test.cpp ExpectationBoundary_test.cpp \ - Verifiable_test.cpp Exception_test.cpp mockpp_test.cpp ReturnObjectList_test.cpp \ - VisitableMockObject_template_test.cpp Assert_test.cpp AssertMo_test.cpp MockObject_test.cpp \ - VisitableMockObject_1_test.cpp VisitableMockObject_2_test.cpp VisitableMockObject_3_test.cpp \ - VisitableMockObject_4_test.cpp VisitableMockObject_5_test.cpp VisitableMockObject_void_test.cpp \ - VisitableMockObject_1_void_test.cpp VisitableMockObject_2_void_test.cpp \ - VisitableMockObject_3_void_test.cpp VisitableMockObject_4_void_test.cpp \ - VisitableMockObject_5_void_test.cpp VerifyingTestCase_test.cpp classes_ABCDE.cpp \ - VerifyingTestCaller_test.cpp TrackingCounter_test.cpp MixedMockObject_5_test.cpp TimeServer_test.cpp + Formatter_test.cpp Throwable_test.cpp ThrowableList_test.cpp ExpectationCounter_test.cpp \ + ExpectationCounterRange_test.cpp ExpectationMap_test.cpp ExpectationList_test.cpp \ + ConstraintList_test.cpp ExpectationSet_test.cpp ExpectationConglomeration_test.cpp \ + ExpectationSegment_test.cpp ExpectationValue_test.cpp ExpectationBoundary_test.cpp \ + Verifiable_test.cpp Exception_test.cpp mockpp_test.cpp ReturnObjectList_test.cpp \ + VisitableMockObject_template_test.cpp Assert_test.cpp AssertMo_test.cpp MockObject_test.cpp \ + VisitableMockObject_1_test.cpp VisitableMockObject_2_test.cpp VisitableMockObject_3_test.cpp \ + VisitableMockObject_4_test.cpp VisitableMockObject_5_test.cpp VisitableMockObject_void_test.cpp \ + VisitableMockObject_1_void_test.cpp VisitableMockObject_2_void_test.cpp \ + VisitableMockObject_3_void_test.cpp VisitableMockObject_4_void_test.cpp \ + VisitableMockObject_5_void_test.cpp VerifyingTestCase_test.cpp classes_ABCDE.cpp \ + VerifyingTestCaller_test.cpp TrackingCounter_test.cpp MixedMockObject_5_test.cpp TimeServer_test.cpp \ + VisitableMockMethod_2_test.cpp jmock_test_SOURCES = And_test.cpp IsAnything_test.cpp IsCloseTo_test.cpp \ - IsEqual_test.cpp IsGreaterOrEqual_test.cpp IsGreaterThan_test.cpp IsInstanceOf_test.cpp \ - IsLessOrEqual_test.cpp IsLessThan_test.cpp IsNot_test.cpp IsNothing_test.cpp IsSame_test.cpp \ - Or_test.cpp ReturnStub_test.cpp StringContains_test.cpp StubSequence_test.cpp \ - TestFailureStub_test.cpp ThrowStub_test.cpp VoidStub_test.cpp ChainingMockObjectSupport_test.cpp \ - CustomStub_test.cpp DefaultResultStub_test.cpp mock_test.cpp Invocation_test.cpp \ - AnyArgumentsMatcher_test.cpp InvokedRecorder_test.cpp InvokeAtLeastOnceMatcher_test.cpp \ - InvokeOnceMatcher_test.cpp InvokeCountMatcher_test.cpp InvokedAfterMatcher_test.cpp \ - TestFailureMatcher_test.cpp NoArgumentsMatcher_test.cpp ArgumentsMatcher_test.cpp \ - ConstraintSet_test.cpp ArgumentsMatchBuilder_test.cpp InvocationMockerBuilder_test.cpp \ - AbstractDynamicChainingMock_test.cpp AbstractInvocationDispatcher_test.cpp ChainingMockBuilder_test.cpp \ - CoreMock_test.cpp DynamicChainingMockError_test.cpp FIFOInvocationDispatcher_test.cpp \ - InvocationMocker_test.cpp LIFOInvocationDispatcher_test.cpp InvokeAtMostMatcher_test.cpp \ - InvokedBeforeMatcher_test.cpp StubBuilder_test.cpp MatchBuilder_test.cpp \ - InvokeAtLeastMatcher_test.cpp classes_ABCDE.cpp ChainableMockObject_1_test.cpp \ - ChainableMockObject_1_void_test.cpp ChainableMockObject_2_test.cpp ChainableMockObject_2_void_test.cpp \ - ChainableMockObject_3_test.cpp ChainableMockObject_3_void_test.cpp ChainableMockObject_4_test.cpp \ - ChainableMockObject_4_void_test.cpp ChainableMockObject_5_test.cpp ChainableMockObject_5_void_test.cpp \ - ChainableMockObject_test.cpp ChainableMockObject_void_test.cpp TypelessStubSequence_test.cpp \ - StringEndsWith_test.cpp StringStartsWith_test.cpp UnlimitedMatcher_test.cpp mockpp_pti_test.cpp \ - OutBound_test.cpp ChainableMockObjectPolymorphism_test.cpp \ - ChainableMockMethod_1_test.cpp + IsEqual_test.cpp IsGreaterOrEqual_test.cpp IsGreaterThan_test.cpp IsInstanceOf_test.cpp \ + IsLessOrEqual_test.cpp IsLessThan_test.cpp IsNot_test.cpp IsNothing_test.cpp IsSame_test.cpp \ + Or_test.cpp ReturnStub_test.cpp StringContains_test.cpp StubSequence_test.cpp \ + TestFailureStub_test.cpp ThrowStub_test.cpp VoidStub_test.cpp ChainingMockObjectSupport_test.cpp \ + CustomStub_test.cpp DefaultResultStub_test.cpp mock_test.cpp Invocation_test.cpp \ + AnyArgumentsMatcher_test.cpp InvokedRecorder_test.cpp InvokeAtLeastOnceMatcher_test.cpp \ + InvokeOnceMatcher_test.cpp InvokeCountMatcher_test.cpp InvokedAfterMatcher_test.cpp \ + TestFailureMatcher_test.cpp NoArgumentsMatcher_test.cpp ArgumentsMatcher_test.cpp \ + ConstraintSet_test.cpp ArgumentsMatchBuilder_test.cpp InvocationMockerBuilder_test.cpp \ + AbstractDynamicChainingMock_test.cpp AbstractInvocationDispatcher_test.cpp ChainingMockBuilder_test.cpp \ + CoreMock_test.cpp DynamicChainingMockError_test.cpp FIFOInvocationDispatcher_test.cpp \ + InvocationMocker_test.cpp LIFOInvocationDispatcher_test.cpp InvokeAtMostMatcher_test.cpp \ + InvokedBeforeMatcher_test.cpp StubBuilder_test.cpp MatchBuilder_test.cpp \ + InvokeAtLeastMatcher_test.cpp classes_ABCDE.cpp ChainableMockObject_1_test.cpp \ + ChainableMockObject_1_void_test.cpp ChainableMockObject_2_test.cpp ChainableMockObject_2_void_test.cpp \ + ChainableMockObject_3_test.cpp ChainableMockObject_3_void_test.cpp ChainableMockObject_4_test.cpp \ + ChainableMockObject_4_void_test.cpp ChainableMockObject_5_test.cpp ChainableMockObject_5_void_test.cpp \ + ChainableMockObject_test.cpp ChainableMockObject_void_test.cpp TypelessStubSequence_test.cpp \ + StringEndsWith_test.cpp StringStartsWith_test.cpp UnlimitedMatcher_test.cpp mockpp_pti_test.cpp \ + OutBound_test.cpp ChainableMockObjectPolymorphism_test.cpp \ + ChainableMockMethod_1_test.cpp ChainableMockMethod_2_test.cpp readability_test_SOURCES = readability_test.cpp classes_ABCDE.cpp --- NEW FILE: VisitableMockMethod_1_test.cpp --- /*************************************************************************** VisitableMockMethod_1_test.cpp - unit tests for VisitableMockObject class and 1 parameter methods ------------------- begin : Thu Oct 2 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de $Id: VisitableMockMethod_1_test.cpp,v 1.1 2005/10/02 18:51:33 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. * ***************************************************************************/ #include <mockpp/mockpp.h> // always first #ifndef HAVE_CPPUNIT # warning CppUnit not available at compile time #else #include <mockpp/VisitableMockMethod.h> #include <mockpp/VisitableMockObject.h> #include <mockpp/constraint/OutBound.h> #include <cppunit/extensions/HelperMacros.h> namespace { // anon class VisitableMockMethod_1_test : public CppUnit::TestFixture { public: CPPUNIT_TEST_SUITE( VisitableMockMethod_1_test ); CPPUNIT_TEST( test_parameter_1 ); CPPUNIT_TEST_SUITE_END(); public: void test_parameter_1(); }; CPPUNIT_TEST_SUITE_REGISTRATION(VisitableMockMethod_1_test); class MyVisitableMockObject_1 : public mockpp::VisitableMockObject { public: MyVisitableMockObject_1(const mockpp::String &name) : mockpp::VisitableMockObject(name, 0) , visitable_mocker(MOCKPP_PCHAR("Visitable"), this) {} int visitable(unsigned i) { return visitable_mocker.forward(i); } mockpp::VisitableMockMethod1<int, unsigned> visitable_mocker; }; void VisitableMockMethod_1_test::test_parameter_1() { MyVisitableMockObject_1 mcm(MOCKPP_PCHAR("Visitable-object")); /* mockpp::VisitableMockMethod1<int, unsigned>::ChainerFor chain(mcm, mcm.Visitable_mocker); CPPUNIT_ASSERT(mcm.Visitable(12) == 21); CPPUNIT_ASSERT(mcm.Visitable(34) == 43); try { mcm.Visitable(56); CPPUNIT_ASSERT_MESSAGE("should have thrown", false); } catch(mockpp::AssertionFailedError &ex) { CPPUNIT_ASSERT(ex.getMessage().find(MOCKPP_PCHAR("unexpected invocation")) != mockpp::String::npos); } */ mcm.verify(); } } // anon ns #endif // HAVE_CPPUNIT Index: ChainableMockMethod_1_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/ChainableMockMethod_1_test.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ChainableMockMethod_1_test.cpp 2 Oct 2005 10:55:47 -0000 1.1 +++ ChainableMockMethod_1_test.cpp 2 Oct 2005 18:51:33 -0000 1.2 @@ -3,7 +3,7 @@ - unit tests for ChainableMockObject class and 1 parameter methods ------------------- - begin : Thu Sep 28 2004 + begin : Thu Oct 2 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de @@ -55,14 +55,12 @@ CPPUNIT_TEST_SUITE( ChainableMockMethod_1_test ); - CPPUNIT_TEST(test_outbound); CPPUNIT_TEST( test_parameter_1 ); CPPUNIT_TEST_SUITE_END(); public: - void test_outbound(); void test_parameter_1(); }; @@ -84,7 +82,7 @@ return chainable_mocker.forward(i); } - mockpp::ChainableMockMethod<int, unsigned> chainable_mocker; + mockpp::ChainableMockMethod1<int, unsigned> chainable_mocker; }; @@ -92,7 +90,7 @@ { MyChainableMockObject_1 mcm(MOCKPP_PCHAR("chainable-object")); - mockpp::ChainerFor<mockpp::ChainableMockMethod<int, unsigned> > chain(mcm, mcm.chainable_mocker); + mockpp::ChainableMockMethod1<int, unsigned>::ChainerFor chain(mcm, mcm.chainable_mocker); chain.stubs(mockpp::once()) .with(mockpp::eq((unsigned int) 12)) @@ -119,27 +117,6 @@ } -void ChainableMockMethod_1_test::test_outbound() -{ - MyChainableMockObject_1 mcm(MOCKPP_PCHAR("chainable-object")); -/* - MOCKPP_CHAINER_FOR_EXT(MyChainableMockObject_1ex, outbound, Ext) chain(&mcm); - - chain.stubs(mockpp::once()) - .with(mockpp::outBound( (unsigned int) 123)); - - chain.stubs(mockpp::once()) - .with(mockpp::outBound( (unsigned int) 456)); - - unsigned val = 0; - mcm.outbound(val); - CPPUNIT_ASSERT_EQUAL((unsigned)123, val); - mcm.outbound(val); - CPPUNIT_ASSERT_EQUAL((unsigned)456, val); -*/ -} - - } // anon ns --- NEW FILE: ChainableMockMethod_2_test.cpp --- /*************************************************************************** ChainableMockMethod_2_test.cpp - unit tests for ChainableMockObject class and 2 parameter methods ------------------- begin : Thu Oct 2 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de $Id: ChainableMockMethod_2_test.cpp,v 1.1 2005/10/02 18:51:33 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. * ***************************************************************************/ #include <mockpp/mockpp.h> // always first #ifndef HAVE_CPPUNIT # warning CppUnit not available at compile time #else #include <mockpp/chaining/ChainableMockMethod.h> #include <mockpp/chaining/ChainingMockObjectSupport.h> #include <mockpp/chaining/Invocation.h> #include <mockpp/constraint/OutBound.h> #include <cppunit/extensions/HelperMacros.h> namespace { // anon class ChainableMockMethod_2_test : public CppUnit::TestFixture { public: CPPUNIT_TEST_SUITE( ChainableMockMethod_2_test ); CPPUNIT_TEST( test_parameter_2 ); CPPUNIT_TEST_SUITE_END(); public: void test_parameter_2(); }; CPPUNIT_TEST_SUITE_REGISTRATION(ChainableMockMethod_2_test); class MyChainableMockObject_2 : public mockpp::ChainableMockObject { public: MyChainableMockObject_2(const mockpp::String &name) : mockpp::ChainableMockObject(name, 0) , chainable_mocker(MOCKPP_PCHAR("chainable"), this) {} int chainable(unsigned i, long l) { return chainable_mocker.forward(i, l); } mockpp::ChainableMockMethod2<int, unsigned, long> chainable_mocker; }; void ChainableMockMethod_2_test::test_parameter_2() { MyChainableMockObject_2 mcm(MOCKPP_PCHAR("chainable-object")); mockpp::ChainableMockMethod2<int, unsigned, long>::ChainerFor chain(mcm, mcm.chainable_mocker); chain.stubs(mockpp::once()) .with(mockpp::eq<unsigned>(12u), mockpp::eq<long>(23)) .will(new mockpp::ReturnStub<int>(21)); chain.stubs(mockpp::once()) .with(mockpp::eq<unsigned>(34), mockpp::eq<long>(45)) .will(new mockpp::ReturnStub<int>(43)); CPPUNIT_ASSERT(mcm.chainable(12, 23) == 21); CPPUNIT_ASSERT(mcm.chainable(34, 45) == 43); try { mcm.chainable(56, 67); CPPUNIT_ASSERT_MESSAGE("should have thrown", false); } catch(mockpp::AssertionFailedError &ex) { CPPUNIT_ASSERT(ex.getMessage().find(MOCKPP_PCHAR("unexpected invocation")) != mockpp::String::npos); } mcm.verify(); } } // anon ns #endif // HAVE_CPPUNIT |