[Mockpp-commits] mockpp/mockpp/tests OutBound_test.cpp,NONE,1.1 Makefile.am,1.76,1.77 ReturnObjectLi
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-07-23 13:32:14
|
Update of /cvsroot/mockpp/mockpp/mockpp/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28014/mockpp/tests Modified Files: Makefile.am ReturnObjectList_test.cpp VisitableMockObject_1_void_test.cpp Added Files: OutBound_test.cpp Log Message: OutBound new Index: VisitableMockObject_1_void_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/VisitableMockObject_1_void_test.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- VisitableMockObject_1_void_test.cpp 27 Feb 2005 18:04:29 -0000 1.17 +++ VisitableMockObject_1_void_test.cpp 23 Jul 2005 13:31:57 -0000 1.18 @@ -44,6 +44,7 @@ #include <mockpp/constraint/IsEqual.h> #include <mockpp/constraint/IsNot.h> +#include <mockpp/constraint/OutBound.h> #include <cppunit/extensions/HelperMacros.h> @@ -58,6 +59,7 @@ CPPUNIT_TEST(test_parameter_ex); CPPUNIT_TEST(test_thrower); CPPUNIT_TEST(test_clear); + CPPUNIT_TEST(test_outbound); CPPUNIT_TEST(test_default_throw); CPPUNIT_TEST(test_constraint); CPPUNIT_TEST(test_controller_constraint); @@ -76,6 +78,7 @@ void test_controller(); void test_thrower(); void test_clear(); + void test_outbound(); void test_default_throw(); void test_parameter(); void test_parameter_ex(); @@ -122,12 +125,16 @@ MyVisitableMockObject_1_void_ex(const mockpp::String &name) : mockpp::VisitableMockObject(name, 0), MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_VISITABLE_EXT1(visitable1, Ext), + MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_VISITABLE_EXT1(outbound, Ext), MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_VISITABLE_EXT0(visitable0, Ext) {} MOCKPP_VOID_VISITABLE_EXT1(MyVisitableMockObject_1_void_ex, visitable1, const std::string &, Ext, std::string); + MOCKPP_VOID_VISITABLE_EXT1(MyVisitableMockObject_1_void_ex, outbound, unsigned &, + Ext, unsigned ); + MOCKPP_VOID_VISITABLE_EXT0(MyVisitableMockObject_1_void_ex, visitable0, Ext); @@ -382,4 +389,21 @@ } +void VisitableMockObject_1_void_test::test_outbound() +{ + MyVisitableMockObject_1_void_ex mvo(MOCKPP_PCHAR("mvo")); + MOCKPP_CONTROLLER_FOR_EXT(MyVisitableMockObject_1_void_ex, outbound, Ext) ctr1 (&mvo); + + mvo.outbound(new mockpp::OutBound<unsigned>(123)); + mvo.outbound(new mockpp::OutBound<unsigned>(456)); + mvo.activate(); + + unsigned val = 0; + mvo.outbound(val); + CPPUNIT_ASSERT_EQUAL((unsigned)123, val); + mvo.outbound(val); + CPPUNIT_ASSERT_EQUAL((unsigned)456, val); +} + + #endif // HAVE_CPPUNIT Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/Makefile.am,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- Makefile.am 7 May 2005 17:14:02 -0000 1.76 +++ Makefile.am 23 Jul 2005 13:31:57 -0000 1.77 @@ -55,25 +55,26 @@ VerifyingTestCaller_test.cpp TrackingCounter_test.cpp MixedMockObject_5_test.cpp TimeServer_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 + 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 readability_test_SOURCES = readability_test.cpp classes_ABCDE.cpp Index: ReturnObjectList_test.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/tests/ReturnObjectList_test.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- ReturnObjectList_test.cpp 28 Mar 2005 09:39:05 -0000 1.12 +++ ReturnObjectList_test.cpp 23 Jul 2005 13:31:57 -0000 1.13 @@ -47,6 +47,7 @@ CPPUNIT_TEST(test_get_object); CPPUNIT_TEST(test_default); + CPPUNIT_TEST(test_tostring); CPPUNIT_TEST_EXCEPTION(fail_get_object, mockpp::AssertionFailedError); CPPUNIT_TEST_EXCEPTION(fail_not_empty, mockpp::AssertionFailedError); @@ -57,6 +58,7 @@ void test_get_object(); void test_default(); + void test_tostring(); void fail_get_object(); void fail_not_empty(); @@ -142,5 +144,17 @@ CPPUNIT_ASSERT(!rol.hasMoreObjects()); } +void ReturnObjectList_test::test_tostring() +{ + mockpp::ReturnObjectList<unsigned> rol (MOCKPP_PCHAR("data"), 0); + CPPUNIT_ASSERT(MOCKPP_PCSTRING("[]") == rol.toString()); + + rol.addObjectToReturn(456); + CPPUNIT_ASSERT(MOCKPP_PCSTRING("\n[\n - 456\n]\n") == rol.toString()); + + rol.setDefaultReturnVaue(123); + CPPUNIT_ASSERT(MOCKPP_PCSTRING("\n[\n - 456\n * 123\n]\n") == rol.toString()); +} + #endif // HAVE_CPPUNIT --- NEW FILE: OutBound_test.cpp --- /*************************************************************************** OutBound_test.cpp - unit tests for OutBound class ------------------- begin : Sat Jul 23 2005 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de $Id: OutBound_test.cpp,v 1.1 2005/07/23 13:31:57 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/constraint/OutBound.h> #include <cppunit/extensions/HelperMacros.h> class OutBound_test : public CppUnit::TestFixture { public: CPPUNIT_TEST_SUITE( OutBound_test ); CPPUNIT_TEST(test_describe); CPPUNIT_TEST(test_invoke); CPPUNIT_TEST_SUITE_END(); public: void test_describe(); void test_invoke(); }; CPPUNIT_TEST_SUITE_REGISTRATION(OutBound_test); void OutBound_test::test_describe() { mockpp::OutBound<int> myequal (456); mockpp::String s; CPPUNIT_ASSERT(myequal.describeTo(s) == MOCKPP_PCHAR("returns \n[\n - 456\n]\n")); CPPUNIT_ASSERT(s == MOCKPP_PCHAR("returns \n[\n - 456\n]\n")); } void OutBound_test::test_invoke() { mockpp::OutBound<mockpp::String> myequal (MOCKPP_PCHAR("string-1")); myequal.addOutboundObject(MOCKPP_PCHAR("string-2")); mockpp::String s; CPPUNIT_ASSERT(myequal.eval(s) == true); CPPUNIT_ASSERT(s == MOCKPP_PCHAR("string-1")); CPPUNIT_ASSERT(myequal.eval(s) == true); CPPUNIT_ASSERT(s == MOCKPP_PCHAR("string-2")); CPPUNIT_ASSERT(myequal.eval(s) == false); } #endif // HAVE_CPPUNIT |