[Mockpp-commits] mockpp/mockpp/examples/tutorial tut-basic.dox,1.3,1.4 tut-chain.dox,1.10,1.11 tut-c
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-11-19 19:14:20
|
Update of /cvsroot/mockpp/mockpp/mockpp/examples/tutorial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8873/mockpp/examples/tutorial Modified Files: tut-basic.dox tut-chain.dox tut-chain2.dox tut-poor-se.dox tut-visit.dox tut-visit2.dox Log Message: cleanup docs Index: tut-chain.dox =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/tut-chain.dox,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- tut-chain.dox 18 Nov 2005 10:58:55 -0000 1.10 +++ tut-chain.dox 19 Nov 2005 19:14:11 -0000 1.11 @@ -27,12 +27,12 @@ using mockpp::throwException; \endcode -A more convenient way is to place a \c \#define before including the mockpp headers +A more convenient way is to place a \c #define before including the mockpp headers which imports all these shortcut functions into the global namespace: \code -\#define MOCKPP_IMPORT_ABBREVIATED -\#include <mockpp/chaining/ChainingMockObjectSupport.h> +#define MOCKPP_IMPORT_ABBREVIATED +#include <mockpp/chaining/ChainingMockObjectSupport.h> \endcode The next solution of the know testing problem @@ -47,12 +47,12 @@ \code class ChainMock : public Interface - , public mockpp::ChainableMockObject + , public ChainableMockObject { public: ChainMock() - : mockpp::ChainableMockObject(MOCKPP_PCHAR("ChainMock"), 0) + : ChainableMockObject("ChainMock", 0) , MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_CHAINABLE_EXT1(open, ext) , MOCKPP_CONSTRUCT_MEMBERS_FOR_CHAINABLE0(read) , MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_CHAINABLE_EXT1(write, ext) Index: tut-poor-se.dox =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/tut-poor-se.dox,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tut-poor-se.dox 19 Feb 2005 14:36:57 -0000 1.2 +++ tut-poor-se.dox 19 Nov 2005 19:14:11 -0000 1.3 @@ -20,24 +20,24 @@ \code class PoorMockSecondEdition : public Interface - , public mockpp::MockObject + , public MockObject { - mockpp::TrackingCounterMaster counter; + TrackingCounterMaster counter; public: - mockpp::TrackingCounterClient open_counter; - mockpp::TrackingCounterClient read_counter; - mockpp::TrackingCounterClient write_counter; - mockpp::TrackingCounterClient close_counter; + TrackingCounterClient open_counter; + TrackingCounterClient read_counter; + TrackingCounterClient write_counter; + TrackingCounterClient close_counter; PoorMockSecondEdition() - : mockpp::MockObject(MOCKPP_PCHAR("MockObject")) - , counter(MOCKPP_PCHAR("counter"), this) - , open_counter(MOCKPP_PCHAR("open_counter"), counter) - , read_counter(MOCKPP_PCHAR("read_counter"), counter) - , write_counter(MOCKPP_PCHAR("write_counter"), counter) - , close_counter(MOCKPP_PCHAR("close_counter"), counter) + : MockObject("MockObject") + , counter("counter", this) + , open_counter("open_counter", counter) + , read_counter("read_counter", counter) + , write_counter("write_counter", counter) + , close_counter("close_counter", counter) { } \endcode Index: tut-visit2.dox =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/tut-visit2.dox,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tut-visit2.dox 18 Nov 2005 18:07:38 -0000 1.3 +++ tut-visit2.dox 19 Nov 2005 19:14:11 -0000 1.4 @@ -43,12 +43,12 @@ public: VisitMock() - : VisitableMockObject(MOCKPP_PCHAR("VisitMock"), 0) - , open_mocker(MOCKPP_PCHAR("open"), this) - , read_mocker(MOCKPP_PCHAR("read"), this) - , write_mocker(MOCKPP_PCHAR("write"), this) - , close_mocker(MOCKPP_PCHAR("close"), this) - , calculate_mocker(MOCKPP_PCHAR("calculate"), this) + : VisitableMockObject("VisitMock", 0) + , open_mocker("open", this) + , read_mocker("read", this) + , write_mocker("write", this) + , close_mocker("close", this) + , calculate_mocker("calculate", this) {} \endcode Index: tut-visit.dox =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/tut-visit.dox,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- tut-visit.dox 18 Nov 2005 10:58:55 -0000 1.9 +++ tut-visit.dox 19 Nov 2005 19:14:11 -0000 1.10 @@ -21,7 +21,7 @@ or by <em>visting</em> the mock object. First the a container mock object must be implemeneted. Similar to the first solution -is must inherit from \c Interface and from \c mockpp::VisitableMockObject . +is must inherit from \c Interface and from \c VisitableMockObject . All the functionality is hidden in internal variables and helper methods. There is a set of variables for each method which must be initialized in the constructor. This work is done with a macro. The macro name depends on the type of method and the number of @@ -30,12 +30,12 @@ \code class VisitMock : public Interface - , public mockpp::VisitableMockObject + , public VisitableMockObject { public: VisitMock() - : mockpp::VisitableMockObject("VisitMock", 0) + : VisitableMockObject("VisitMock", 0) , MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_VISITABLE_EXT1(open, ext) , MOCKPP_CONSTRUCT_MEMBERS_FOR_VISITABLE0(read) , MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_VISITABLE_EXT1(write, ext) @@ -135,7 +135,7 @@ Another rather common problem is the simulation of runtime errors. Such errors happen usually when you don't expect them but you hardly can reproduce them. To address such -testing problems you might use a \c mockpp::Throwable . The following code could +testing problems you might use a \c Throwable . The following code could be used to emulate a method that returns bytes from a network connection. The first 10 calls return 0, but the next call throws a \c NetworkError . All the following calls return 1. @@ -146,7 +146,7 @@ MOCKPP_CONTROLLER_FOR(VisitMock, network_read) read_controller (&mock); read_controller.addReturnValue(0, 10); - read_controller.addThrowable(mockpp::make_throwable(NetworkError())); + read_controller.addThrowable(make_throwable(NetworkError())); read_controller.setDefaultValue(1); \endcode @@ -157,7 +157,7 @@ Since the parameters passed to \c calculate are not exactly defined we must implement some tolerance. This can be achieved with an according constraint. In this case -\c mockpp::IsCloseTo which allows a delta value. +\c IsCloseTo which allows a delta value. \code mock.calculate(eq<unsigned>(5,5)); Index: tut-basic.dox =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/tut-basic.dox,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tut-basic.dox 4 Mar 2005 23:37:00 -0000 1.3 +++ tut-basic.dox 19 Nov 2005 19:14:11 -0000 1.4 @@ -17,11 +17,11 @@ The first solution will use basic mock objects to express the needed expectations. Additionally there is a container object to hold and verify all those tiny mock objects. The container must inherit from the \c Interface class as well as -from the root of all more advanced mock objects \c mockpp::MockObject : +from the root of all more advanced mock objects \c MockObject : \code class BasicMock : public Interface - , public mockpp::MockObject + , public MockObject { public: \endcode @@ -35,7 +35,7 @@ \code BasicMock() - : mockpp::MockObject("BasicMock", 0) + : MockObject("BasicMock", 0) , open_name("BasicMock/open_name", this) , close_counter("BasicMock/close_counter", this) , write_data("BasicMock/write_data", this) @@ -48,13 +48,13 @@ Depending on your personal taste you can simply use public member variables or hide them and offer getter and setter methods. -To verify the calls to \c open() a \c mockpp::ExpectationList is used. This way +To verify the calls to \c open() a \c ExpectationList is used. This way all the actual values are checked against the expectations one after the other. As a side effect the total number of calls to \c open() is verified since the count of actual and expected values have to be equal. \code - mockpp::ExpectationList<std::string> open_name; + ExpectationList<std::string> open_name; virtual void open(const std::string &name) { @@ -63,12 +63,12 @@ \endcode The implementation of method \c read() needs a different approach. To return -a predefined set of values an object of type \c mockpp::ReturnObjectList is +a predefined set of values an object of type \c ReturnObjectList is used. And again the additional benefit is the fact that the total number of calls must equal the number of return values. \code - mockpp::ReturnObjectList<std::string> read_data; + ReturnObjectList<std::string> read_data; virtual std::string read() { @@ -78,10 +78,10 @@ A third alternative is chosen to to verify the correct number of calls to \c close(). Since there are no parameters or return values the only -possibility is to take \c mockpp::ExpectationCounter . +possibility is to take \c ExpectationCounter . \code - mockpp::ExpectationCounter close_counter; + ExpectationCounter close_counter; virtual void close() { @@ -106,7 +106,7 @@ \endcode Next you have to provide the appropriate number of return values for the \c read() method. -They are added in the expected order to the \c mockpp::ReturnObjectList : +They are added in the expected order to the \c ReturnObjectList : \code mock.read_data.addObjectToReturn("record-1"); @@ -115,8 +115,8 @@ \endcode While processing the records a method \c calculate is invoked several times. Since the input -can't be determined exactly a \c mockpp::ConstraintList is used which verifies similar to -a mockpp::ExpectationList but on the base of a mean amount and a delta value. +can't be determined exactly a \c ConstraintList is used which verifies similar to +a ExpectationList but on the base of a mean amount and a delta value. \code mock.calculate_input.addExpected(eq<unsigned>(5,5)); @@ -125,7 +125,7 @@ \endcode The number of calls to \c close() must equal the calls to \c open() . For that reason -the according \c mockpp::ExpectationCounter is set to 2: +the according \c ExpectationCounter is set to 2: \code mock.close_counter.setExpected(2); Index: tut-chain2.dox =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/tut-chain2.dox,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tut-chain2.dox 18 Nov 2005 18:07:38 -0000 1.3 +++ tut-chain2.dox 19 Nov 2005 19:14:11 -0000 1.4 @@ -31,12 +31,12 @@ public: ChainMock() - : ChainableMockObject(MOCKPP_PCHAR("ChainMock"), 0) - , open_mocker(MOCKPP_PCHAR("open"), this) - , read_mocker(MOCKPP_PCHAR("read"), this) - , write_mocker(MOCKPP_PCHAR("write"), this) - , close_mocker(MOCKPP_PCHAR("close"), this) - , calculate_mocker(MOCKPP_PCHAR("calculate"), this) + : ChainableMockObject("ChainMock", 0) + , open_mocker("open", this) + , read_mocker("read", this) + , write_mocker("write", this) + , close_mocker("close", this) + , calculate_mocker("calculate", this) {} void open(const std::string &filename) |