[Mockpp-commits] mockpp/mockpp/examples/tutorial basicmock.cpp,1.7,1.8 chainmock.cpp,1.10,1.11 chain
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-11-26 17:58:48
|
Update of /cvsroot/mockpp/mockpp/mockpp/examples/tutorial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20828/mockpp/examples/tutorial Modified Files: basicmock.cpp chainmock.cpp chainmock2.cpp consumer.h interface.h poormock-se.cpp poormock.cpp visitmock.cpp visitmock2.cpp Log Message: prepare use of alternative stl Index: visitmock2.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/visitmock2.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- visitmock2.cpp 18 Nov 2005 10:23:27 -0000 1.1 +++ visitmock2.cpp 26 Nov 2005 17:58:40 -0000 1.2 @@ -39,17 +39,17 @@ , calculate_mocker(MOCKPP_PCHAR("calculate"), this) {} - void open(const std::string &filename) + void open(const MOCKPP_STL::string &filename) { open_mocker.forward(filename); } - std::string read() + MOCKPP_STL::string read() { return read_mocker.forward(); } - void write(const std::string &data) + void write(const MOCKPP_STL::string &data) { write_mocker.forward(data); } @@ -59,7 +59,7 @@ return calculate_mocker.forward(input); } - void write(const mockpp::ConstraintHolder<std::string> &ch) + void write(const mockpp::ConstraintHolder<MOCKPP_STL::string> &ch) { write_mocker.forward(ch); } @@ -74,9 +74,9 @@ close_mocker.forward(); } - mockpp::VisitableMockMethod<void, std::string> open_mocker; - mockpp::VisitableMockMethod<std::string> read_mocker; - mockpp::VisitableMockMethod<void, std::string> write_mocker; + mockpp::VisitableMockMethod<void, MOCKPP_STL::string> open_mocker; + mockpp::VisitableMockMethod<MOCKPP_STL::string> read_mocker; + mockpp::VisitableMockMethod<void, MOCKPP_STL::string> write_mocker; mockpp::VisitableMockMethod<void> close_mocker; mockpp::VisitableMockMethod<unsigned, unsigned> calculate_mocker; }; @@ -87,7 +87,7 @@ try { VisitMock mock; - mockpp::VisitableMockMethod<std::string> &read_controller (mock.read_mocker); + mockpp::VisitableMockMethod<MOCKPP_STL::string> &read_controller (mock.read_mocker); mockpp::VisitableMockMethod<unsigned, unsigned> &calculate_controller (mock.calculate_mocker); // record program flow while reading data @@ -122,8 +122,8 @@ // record program flow while writing data mock.open("file1.lst"); mock.write("record-1/processed"); - mock.write(stringContains(std::string("processed"))); - mock.write(stringContains(std::string("processed"))); + mock.write(stringContains(MOCKPP_STL::string("processed"))); + mock.write(stringContains(MOCKPP_STL::string("processed"))); mock.close(); // activate mock object Index: poormock-se.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/poormock-se.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- poormock-se.cpp 5 Apr 2005 18:44:05 -0000 1.5 +++ poormock-se.cpp 26 Nov 2005 17:58:40 -0000 1.6 @@ -40,18 +40,18 @@ { } - virtual void open(const std::string & /* name */) + virtual void open(const MOCKPP_STL::string & /* name */) { open_counter++; } - virtual std::string read() + virtual MOCKPP_STL::string read() { read_counter++; return "dummy"; } - virtual void write(const std::string & /* s */) + virtual void write(const MOCKPP_STL::string & /* s */) { write_counter++; } Index: visitmock.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/visitmock.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- visitmock.cpp 9 Oct 2005 13:51:54 -0000 1.14 +++ visitmock.cpp 26 Nov 2005 17:58:40 -0000 1.15 @@ -38,13 +38,13 @@ , MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_VISITABLE0(close) {} - MOCKPP_VOID_VISITABLE_EXT1(VisitMock, open, const std::string &, - ext, std::string); + MOCKPP_VOID_VISITABLE_EXT1(VisitMock, open, const MOCKPP_STL::string &, + ext, MOCKPP_STL::string); - MOCKPP_VISITABLE0(VisitMock, std::string, read); + MOCKPP_VISITABLE0(VisitMock, MOCKPP_STL::string, read); - MOCKPP_VOID_VISITABLE_EXT1(VisitMock, write, const std::string &, - ext, std::string); + MOCKPP_VOID_VISITABLE_EXT1(VisitMock, write, const MOCKPP_STL::string &, + ext, MOCKPP_STL::string); MOCKPP_VISITABLE_EXT1(VisitMock, unsigned, calculate, unsigned, unsigned, ext, unsigned); @@ -73,28 +73,28 @@ read_controller.addReturnValue("record-2"); read_controller.addReturnValue("record-3"); - // processing is not exactly defined + // processing is not exactly defined #if defined(_MSC_VER) && _MSC_VER <= 1300 - mock.calculate(new mockpp::IsCloseTo<unsigned>(5, 5)); - mock.calculate(new mockpp::IsCloseTo<unsigned>(5, 5)); - mock.calculate(new mockpp::IsCloseTo<unsigned>(5, 5)); - calculate_controller.addResponseValue(10, new mockpp::IsCloseTo<unsigned>(2, 2)); - calculate_controller.addResponseValue(20, new mockpp::IsCloseTo<unsigned>(4, 2)); - calculate_controller.addResponseValue(30, new mockpp::IsCloseTo<unsigned>(6, 2)); -#else - mock.calculate(eq<unsigned>(5, 5)); - mock.calculate(eq<unsigned>(5, 5)); + mock.calculate(new mockpp::IsCloseTo<unsigned>(5, 5)); + mock.calculate(new mockpp::IsCloseTo<unsigned>(5, 5)); + mock.calculate(new mockpp::IsCloseTo<unsigned>(5, 5)); + calculate_controller.addResponseValue(10, new mockpp::IsCloseTo<unsigned>(2, 2)); + calculate_controller.addResponseValue(20, new mockpp::IsCloseTo<unsigned>(4, 2)); + calculate_controller.addResponseValue(30, new mockpp::IsCloseTo<unsigned>(6, 2)); +#else mock.calculate(eq<unsigned>(5, 5)); - calculate_controller.addResponseValue(10, eq<unsigned>(2, 2)); - calculate_controller.addResponseValue(20, eq<unsigned>(4, 2)); - calculate_controller.addResponseValue(30, eq<unsigned>(6, 2)); -#endif + mock.calculate(eq<unsigned>(5, 5)); + mock.calculate(eq<unsigned>(5, 5)); + calculate_controller.addResponseValue(10, eq<unsigned>(2, 2)); + calculate_controller.addResponseValue(20, eq<unsigned>(4, 2)); + calculate_controller.addResponseValue(30, eq<unsigned>(6, 2)); +#endif // record program flow while writing data mock.open("file1.lst"); mock.write("record-1/processed"); - mock.write(stringContains(std::string("processed"))); - mock.write(stringContains(std::string("processed"))); + mock.write(stringContains(MOCKPP_STL::string("processed"))); + mock.write(stringContains(MOCKPP_STL::string("processed"))); mock.close(); // activate mock object Index: consumer.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/consumer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- consumer.h 30 Apr 2005 15:06:05 -0000 1.4 +++ consumer.h 26 Nov 2005 17:58:40 -0000 1.5 @@ -40,8 +40,8 @@ private: Interface *configfile; - std::string config1; - std::string config2; - std::string config3; + MOCKPP_STL::string config1; + MOCKPP_STL::string config2; + MOCKPP_STL::string config3; }; Index: chainmock2.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/chainmock2.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- chainmock2.cpp 18 Nov 2005 10:31:30 -0000 1.1 +++ chainmock2.cpp 26 Nov 2005 17:58:40 -0000 1.2 @@ -39,17 +39,17 @@ , calculate_mocker(MOCKPP_PCHAR("calculate"), this) {} - void open(const std::string &filename) + void open(const MOCKPP_STL::string &filename) { open_mocker.forward(filename); } - std::string read() + MOCKPP_STL::string read() { return read_mocker.forward(); } - void write(const std::string &data) + void write(const MOCKPP_STL::string &data) { write_mocker.forward(data); } @@ -64,9 +64,9 @@ close_mocker.forward(); } - mockpp::ChainableMockMethod<void, std::string> open_mocker; - mockpp::ChainableMockMethod<std::string> read_mocker; - mockpp::ChainableMockMethod<void, std::string> write_mocker; + mockpp::ChainableMockMethod<void, MOCKPP_STL::string> open_mocker; + mockpp::ChainableMockMethod<MOCKPP_STL::string> read_mocker; + mockpp::ChainableMockMethod<void, MOCKPP_STL::string> write_mocker; mockpp::ChainableMockMethod<void> close_mocker; mockpp::ChainableMockMethod<unsigned, unsigned> calculate_mocker; }; @@ -78,21 +78,21 @@ { ChainMock mock; - mockpp::ChainableMockMethod<void, std::string> &open_chainer (mock.open_mocker); - mockpp::ChainableMockMethod<std::string> &read_chainer (mock.read_mocker); - mockpp::ChainableMockMethod<void, std::string> &write_chainer (mock.write_mocker); + mockpp::ChainableMockMethod<void, MOCKPP_STL::string> &open_chainer (mock.open_mocker); + mockpp::ChainableMockMethod<MOCKPP_STL::string> &read_chainer (mock.read_mocker); + mockpp::ChainableMockMethod<void, MOCKPP_STL::string> &write_chainer (mock.write_mocker); mockpp::ChainableMockMethod<void> &close_chainer (mock.close_mocker); mockpp::ChainableMockMethod<unsigned, unsigned> &calculate_chainer (mock.calculate_mocker); // Expectations for reading the file open_chainer.expects(once()) - .with(eq(std::string("file1.lst"))) + .with(eq(MOCKPP_STL::string("file1.lst"))) .before(MOCKPP_PCHAR("reader")); read_chainer.stubs() - .will(onConsecutiveCalls(new ReturnStub<std::string>("record-1"), - new ReturnStub<std::string>("record-2"), - new ReturnStub<std::string>("record-3"))) + .will(onConsecutiveCalls(new ReturnStub<MOCKPP_STL::string>("record-1"), + new ReturnStub<MOCKPP_STL::string>("record-2"), + new ReturnStub<MOCKPP_STL::string>("record-3"))) .id(MOCKPP_PCHAR("reader")); close_chainer.expects(once()) @@ -107,15 +107,15 @@ // Expectations for writing the file back open_chainer.expects(once()) - .with(eq(std::string("file1.lst"))) + .with(eq(MOCKPP_STL::string("file1.lst"))) .before(MOCKPP_PCHAR("writer")); write_chainer.expects(once()) - .with(eq(std::string("record-1/processed"))); + .with(eq(MOCKPP_STL::string("record-1/processed"))); write_chainer.expects(once()) - .with(eq(std::string("record-2/processed"))); + .with(eq(MOCKPP_STL::string("record-2/processed"))); write_chainer.expects(once()) - .with(stringContains(std::string("processed"))) + .with(stringContains(MOCKPP_STL::string("processed"))) .id(MOCKPP_PCHAR("writer")); close_chainer.expects(once()) Index: interface.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/interface.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- interface.h 5 Apr 2005 18:44:05 -0000 1.6 +++ interface.h 26 Nov 2005 17:58:40 -0000 1.7 @@ -50,17 +50,17 @@ /** Opens the file * @param name name of file to open */ - virtual void open(const std::string &name) = 0; + virtual void open(const MOCKPP_STL::string &name) = 0; /** Reads one record from the file * @return the record (one complete line) */ - virtual std::string read() = 0; + virtual MOCKPP_STL::string read() = 0; /** Writes a record to the file * @param s the record (one complete line) */ - virtual void write(const std::string &s) = 0; + virtual void write(const MOCKPP_STL::string &s) = 0; /** Does some calculating * @param input ingoing data Index: poormock.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/poormock.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- poormock.cpp 3 Apr 2005 18:32:53 -0000 1.8 +++ poormock.cpp 26 Nov 2005 17:58:40 -0000 1.9 @@ -14,10 +14,10 @@ #include "consumer.h" #include <iostream> - -#ifndef _MSC_VER -using std::exit; -#endif + +#ifndef _MSC_VER +using std::exit; +#endif /** Quick-n-dirty asserter. * If the condition fails the condition is printed @@ -46,18 +46,18 @@ close_counter = 0; } - virtual void open(const std::string & /* name */) + virtual void open(const MOCKPP_STL::string & /* name */) { open_counter = ++counter; } - virtual std::string read() + virtual MOCKPP_STL::string read() { read_counter = ++counter; return "dummy"; } - virtual void write(const std::string & /* s */) + virtual void write(const MOCKPP_STL::string & /* s */) { write_counter = ++counter; } Index: basicmock.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/basicmock.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- basicmock.cpp 5 Apr 2005 18:44:04 -0000 1.7 +++ basicmock.cpp 26 Nov 2005 17:58:40 -0000 1.8 @@ -46,17 +46,17 @@ { } - virtual void open(const std::string &name) + virtual void open(const MOCKPP_STL::string &name) { open_name.addActual(name); } - virtual std::string read() + virtual MOCKPP_STL::string read() { return read_data.nextReturnObject(); } - virtual void write(const std::string &s) + virtual void write(const MOCKPP_STL::string &s) { write_data.addActual(s); } @@ -72,10 +72,10 @@ close_counter.inc(); } - mockpp::ExpectationList<std::string> open_name; + mockpp::ExpectationList<MOCKPP_STL::string> open_name; mockpp::ExpectationCounter close_counter; - mockpp::ExpectationList<std::string> write_data; - mockpp::ReturnObjectList<std::string> read_data; + mockpp::ExpectationList<MOCKPP_STL::string> write_data; + mockpp::ReturnObjectList<MOCKPP_STL::string> read_data; mockpp::ReturnObjectList<unsigned> calculate_output; mockpp::ConstraintList<unsigned > calculate_input; }; Index: chainmock.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/chainmock.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- chainmock.cpp 6 Apr 2005 19:25:56 -0000 1.10 +++ chainmock.cpp 26 Nov 2005 17:58:40 -0000 1.11 @@ -23,10 +23,10 @@ #include <iostream> using namespace mockpp; - - -typedef mockpp::Invocation1<std::string> InvocationString; -typedef mockpp::Invocation1<unsigned> InvocationUInt; + + +typedef mockpp::Invocation1<MOCKPP_STL::string> InvocationString; +typedef mockpp::Invocation1<unsigned> InvocationUInt; MOCKPP_PTI_IMPLEMENT(mockpp::Invocation0); MOCKPP_PTI_IMPLEMENT(InvocationString); @@ -47,13 +47,13 @@ , MOCKPP_CONSTRUCT_MEMBERS_FOR_VOID_CHAINABLE0(close) {} - MOCKPP_VOID_CHAINABLE_EXT1(ChainMock, open, const std::string &, - ext, std::string); + MOCKPP_VOID_CHAINABLE_EXT1(ChainMock, open, const MOCKPP_STL::string &, + ext, MOCKPP_STL::string); - MOCKPP_CHAINABLE0(ChainMock, std::string, read); + MOCKPP_CHAINABLE0(ChainMock, MOCKPP_STL::string, read); - MOCKPP_VOID_CHAINABLE_EXT1(ChainMock, write, const std::string &, - ext, std::string); + MOCKPP_VOID_CHAINABLE_EXT1(ChainMock, write, const MOCKPP_STL::string &, + ext, MOCKPP_STL::string); MOCKPP_CHAINABLE_EXT1(ChainMock, unsigned, calculate, unsigned, unsigned, ext, unsigned); @@ -75,13 +75,13 @@ // Expectations for reading the file open_chainer.expects(once()) - .with(eq(std::string("file1.lst"))) + .with(eq(MOCKPP_STL::string("file1.lst"))) .before(MOCKPP_PCHAR("reader")); read_chainer.stubs() - .will(onConsecutiveCalls(new ReturnStub<std::string>("record-1"), - new ReturnStub<std::string>("record-2"), - new ReturnStub<std::string>("record-3"))) + .will(onConsecutiveCalls(new ReturnStub<MOCKPP_STL::string>("record-1"), + new ReturnStub<MOCKPP_STL::string>("record-2"), + new ReturnStub<MOCKPP_STL::string>("record-3"))) .id(MOCKPP_PCHAR("reader")); close_chainer.expects(once()) @@ -96,15 +96,15 @@ // Expectations for writing the file back open_chainer.expects(once()) - .with(eq(std::string("file1.lst"))) + .with(eq(MOCKPP_STL::string("file1.lst"))) .before(MOCKPP_PCHAR("writer")); write_chainer.expects(once()) - .with(eq(std::string("record-1/processed"))); + .with(eq(MOCKPP_STL::string("record-1/processed"))); write_chainer.expects(once()) - .with(eq(std::string("record-2/processed"))); + .with(eq(MOCKPP_STL::string("record-2/processed"))); write_chainer.expects(once()) - .with(stringContains(std::string("processed"))) + .with(stringContains(MOCKPP_STL::string("processed"))) .id(MOCKPP_PCHAR("writer")); close_chainer.expects(once()) |