[Mockpp-commits] mockpp/mockpp/examples/tutorial basicmock.cpp,1.9,1.10 chainmock.cpp,1.14,1.15 chai
Brought to you by:
ewald-arnold
Update of /cvsroot/mockpp/mockpp/mockpp/examples/tutorial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv763/mockpp/examples/tutorial Modified Files: basicmock.cpp chainmock.cpp chainmock2.cpp cppunit.cpp poormock-se.cpp verifying.cpp visitmock.cpp visitmock2.cpp Log Message: optionally disable mockpp namespace Index: cppunit.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/cppunit.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- cppunit.cpp 29 Dec 2005 19:29:51 -0000 1.15 +++ cppunit.cpp 15 Mar 2006 21:34:04 -0000 1.16 @@ -27,21 +27,21 @@ #include "Calculator.h" -using mockpp::eq; -using mockpp::once; -using mockpp::exactly; -using mockpp::returnValue; -using mockpp::throwException; +using MOCKPP_NS::eq; +using MOCKPP_NS::once; +using MOCKPP_NS::exactly; +using MOCKPP_NS::returnValue; +using MOCKPP_NS::throwException; /** A Chainable mock object. * @internal */ -class ChainDemoMock : public mockpp::ChainableMockObject +class ChainDemoMock : public MOCKPP_NS::ChainableMockObject { public: ChainDemoMock() - : mockpp::ChainableMockObject(MOCKPP_PCHAR("ChainDemoMock"), 0) + : MOCKPP_NS::ChainableMockObject(MOCKPP_PCHAR("ChainDemoMock"), 0) , MOCKPP_CONSTRUCT_MEMBERS_FOR_CHAINABLE_EXT2(add, ext) , MOCKPP_CONSTRUCT_MEMBERS_FOR_CHAINABLE0(network_read) {} @@ -56,12 +56,12 @@ /** A Visitable mock object. * @internal */ -class VisitDemoMock : public mockpp::VisitableMockObject +class VisitDemoMock : public MOCKPP_NS::VisitableMockObject { public: VisitDemoMock() - : mockpp::VisitableMockObject(MOCKPP_PCHAR("VisitDemoMock"), 0) + : MOCKPP_NS::VisitableMockObject(MOCKPP_PCHAR("VisitDemoMock"), 0) , MOCKPP_CONSTRUCT_MEMBERS_FOR_VISITABLE_EXT2(add, ext) , MOCKPP_CONSTRUCT_MEMBERS_FOR_VISITABLE0(network_read) {} @@ -238,7 +238,7 @@ read_controller.setDefaultReturnValue(1); read_controller.addReturnValue(0, 10); - read_controller.addThrowable(mockpp::make_throwable(NetworkError())); + read_controller.addThrowable(MOCKPP_NS::make_throwable(NetworkError())); mock.activate(); Index: verifying.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/verifying.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- verifying.cpp 29 Dec 2005 19:29:51 -0000 1.14 +++ verifying.cpp 15 Mar 2006 21:34:04 -0000 1.15 @@ -31,15 +31,15 @@ /** A helper class for the unit tests * @internal */ -class VerifyingCalculator_test : public mockpp::VerifyingTestCase +class VerifyingCalculator_test : public MOCKPP_NS::VerifyingTestCase { public: CPPUNIT_TEST_SUITE( VerifyingCalculator_test ); MOCKPP_TEST(test_ok_no_verify); MOCKPP_VERIFYING_TEST(test_ok); - MOCKPP_VERIFYING_TEST_EXCEPTION(test_fail, mockpp::AssertionFailedError); - MOCKPP_TEST_EXCEPTION(test_fail_no_verify, mockpp::AssertionFailedError); + MOCKPP_VERIFYING_TEST_EXCEPTION(test_fail, MOCKPP_NS::AssertionFailedError); + MOCKPP_TEST_EXCEPTION(test_fail_no_verify, MOCKPP_NS::AssertionFailedError); CPPUNIT_TEST_SUITE_END(); public: @@ -57,7 +57,7 @@ void VerifyingCalculator_test::test_ok_no_verify() { - mockpp::ExpectationValue<int> ev (MOCKPP_PCHAR("ev"), this); + MOCKPP_NS::ExpectationValue<int> ev (MOCKPP_PCHAR("ev"), this); ev.setExpected(123); ev.setActual(123); verify(); @@ -66,23 +66,23 @@ void VerifyingCalculator_test::test_ok() { - mockpp::ExpectationValue<int> *ev = new mockpp::ExpectationValue<int>(MOCKPP_PCHAR("ev")); + MOCKPP_NS::ExpectationValue<int> *ev = new MOCKPP_NS::ExpectationValue<int>(MOCKPP_PCHAR("ev")); registerVerifiable(ev); ev->setExpected(123); ev->setActual(123); ev->verify(); - mockpp::ExpectationValue<int> ev2 (MOCKPP_PCHAR("ev2"), this); + MOCKPP_NS::ExpectationValue<int> ev2 (MOCKPP_PCHAR("ev2"), this); ev2.setExpected(123); ev2.setActual(123); ev2.verify(); - mockpp::ExpectationValue<int> ev3 (MOCKPP_PCHAR("ev3")); + MOCKPP_NS::ExpectationValue<int> ev3 (MOCKPP_PCHAR("ev3")); ev3.setExpected(123); ev3.setActual(123); ev3.verify(); - mockpp::ExpectationValue<int> *ev4 = new mockpp::ExpectationValue<int>(MOCKPP_PCHAR("ev")); + MOCKPP_NS::ExpectationValue<int> *ev4 = new MOCKPP_NS::ExpectationValue<int>(MOCKPP_PCHAR("ev")); registerVerifiable(ev4); ev4->setExpected(123); ev4->setActual(123); @@ -94,7 +94,7 @@ void VerifyingCalculator_test::test_fail_no_verify() { - mockpp::ExpectationValue<int> ev(MOCKPP_PCHAR("ev"), 0) ; + MOCKPP_NS::ExpectationValue<int> ev(MOCKPP_PCHAR("ev"), 0) ; ev.setExpected(123); ev.setActual(123456); } @@ -102,7 +102,7 @@ void VerifyingCalculator_test::test_fail() { - mockpp::ExpectationValue<int> *ev = new mockpp::ExpectationValue<int>(MOCKPP_PCHAR("ev")); + MOCKPP_NS::ExpectationValue<int> *ev = new MOCKPP_NS::ExpectationValue<int>(MOCKPP_PCHAR("ev")); registerVerifiable(ev); ev->setExpected(123); // missing actual Index: visitmock2.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/visitmock2.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- visitmock2.cpp 29 Dec 2005 19:29:51 -0000 1.4 +++ visitmock2.cpp 15 Mar 2006 21:34:04 -0000 1.5 @@ -26,12 +26,12 @@ class VisitMock : public Interface - , public mockpp::VisitableMockObject + , public MOCKPP_NS::VisitableMockObject { public: VisitMock() - : mockpp::VisitableMockObject(MOCKPP_PCHAR("VisitMock"), 0) + : MOCKPP_NS::VisitableMockObject(MOCKPP_PCHAR("VisitMock"), 0) , open_mocker(MOCKPP_PCHAR("open"), this) , read_mocker(MOCKPP_PCHAR("read"), this) , write_mocker(MOCKPP_PCHAR("write"), this) @@ -59,12 +59,12 @@ return calculate_mocker.forward(input); } - void write(const mockpp::ConstraintHolder<MOCKPP_STL::string> &ch) + void write(const MOCKPP_NS::ConstraintHolder<MOCKPP_STL::string> &ch) { write_mocker.forward(ch); } - void calculate(const mockpp::ConstraintHolder<unsigned> &ch) + void calculate(const MOCKPP_NS::ConstraintHolder<unsigned> &ch) { calculate_mocker.forward(ch); } @@ -74,11 +74,11 @@ close_mocker.forward(); } - 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; + MOCKPP_NS::VisitableMockMethod<void, MOCKPP_STL::string> open_mocker; + MOCKPP_NS::VisitableMockMethod<MOCKPP_STL::string> read_mocker; + MOCKPP_NS::VisitableMockMethod<void, MOCKPP_STL::string> write_mocker; + MOCKPP_NS::VisitableMockMethod<void> close_mocker; + MOCKPP_NS::VisitableMockMethod<unsigned, unsigned> calculate_mocker; }; @@ -87,8 +87,8 @@ try { VisitMock mock; - mockpp::VisitableMockMethod<MOCKPP_STL::string> &read_controller (mock.read_mocker); - mockpp::VisitableMockMethod<unsigned, unsigned> &calculate_controller (mock.calculate_mocker); + MOCKPP_NS::VisitableMockMethod<MOCKPP_STL::string> &read_controller (mock.read_mocker); + MOCKPP_NS::VisitableMockMethod<unsigned, unsigned> &calculate_controller (mock.calculate_mocker); // record program flow while reading data mock.open("file1.lst"); @@ -104,12 +104,12 @@ // 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)); + mock.calculate(new MOCKPP_NS::IsCloseTo<unsigned>(5, 5)); + mock.calculate(new MOCKPP_NS::IsCloseTo<unsigned>(5, 5)); + mock.calculate(new MOCKPP_NS::IsCloseTo<unsigned>(5, 5)); + calculate_controller.addResponseValue(10, new MOCKPP_NS::IsCloseTo<unsigned>(2, 2)); + calculate_controller.addResponseValue(20, new MOCKPP_NS::IsCloseTo<unsigned>(4, 2)); + calculate_controller.addResponseValue(30, new MOCKPP_NS::IsCloseTo<unsigned>(6, 2)); #else mock.calculate(eq<unsigned>(5, 5)); mock.calculate(eq<unsigned>(5, 5)); Index: poormock-se.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/poormock-se.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- poormock-se.cpp 29 Dec 2005 19:29:51 -0000 1.7 +++ poormock-se.cpp 15 Mar 2006 21:34:04 -0000 1.8 @@ -22,16 +22,16 @@ class PoorMockSecondEdition : public Interface - , public mockpp::MockObject + , public MOCKPP_NS::MockObject { private: - mockpp::TrackingCounterMaster counter; + MOCKPP_NS::TrackingCounterMaster counter; public: PoorMockSecondEdition() - : mockpp::MockObject(MOCKPP_PCHAR("MockObject")) + : MOCKPP_NS::MockObject(MOCKPP_PCHAR("MockObject")) , counter(MOCKPP_PCHAR("counter"), this) , open_counter(MOCKPP_PCHAR("open_counter"), counter) , read_counter(MOCKPP_PCHAR("read_counter"), counter) @@ -66,10 +66,10 @@ close_counter++; } - mockpp::TrackingCounterClient open_counter; - mockpp::TrackingCounterClient read_counter; - mockpp::TrackingCounterClient write_counter; - mockpp::TrackingCounterClient close_counter; + MOCKPP_NS::TrackingCounterClient open_counter; + MOCKPP_NS::TrackingCounterClient read_counter; + MOCKPP_NS::TrackingCounterClient write_counter; + MOCKPP_NS::TrackingCounterClient close_counter; }; Index: visitmock.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/visitmock.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- visitmock.cpp 29 Dec 2005 19:29:51 -0000 1.17 +++ visitmock.cpp 15 Mar 2006 21:34:04 -0000 1.18 @@ -25,12 +25,12 @@ class VisitMock : public Interface - , public mockpp::VisitableMockObject + , public MOCKPP_NS::VisitableMockObject { public: VisitMock() - : mockpp::VisitableMockObject(MOCKPP_PCHAR("VisitMock"), 0) + : MOCKPP_NS::VisitableMockObject(MOCKPP_PCHAR("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) @@ -75,12 +75,12 @@ // 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)); + mock.calculate(new MOCKPP_NS::IsCloseTo<unsigned>(5, 5)); + mock.calculate(new MOCKPP_NS::IsCloseTo<unsigned>(5, 5)); + mock.calculate(new MOCKPP_NS::IsCloseTo<unsigned>(5, 5)); + calculate_controller.addResponseValue(10, new MOCKPP_NS::IsCloseTo<unsigned>(2, 2)); + calculate_controller.addResponseValue(20, new MOCKPP_NS::IsCloseTo<unsigned>(4, 2)); + calculate_controller.addResponseValue(30, new MOCKPP_NS::IsCloseTo<unsigned>(6, 2)); #else mock.calculate(eq<unsigned>(5, 5)); mock.calculate(eq<unsigned>(5, 5)); Index: chainmock2.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/chainmock2.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- chainmock2.cpp 29 Dec 2005 19:29:51 -0000 1.4 +++ chainmock2.cpp 15 Mar 2006 21:34:04 -0000 1.5 @@ -23,15 +23,15 @@ #include <exception> #include <iostream> -using namespace mockpp; +USING_NAMESPACE_MOCKPP class ChainMock : public Interface - , public mockpp::ChainableMockObject + , public MOCKPP_NS::ChainableMockObject { public: ChainMock() - : mockpp::ChainableMockObject(MOCKPP_PCHAR("ChainMock"), 0) + : MOCKPP_NS::ChainableMockObject(MOCKPP_PCHAR("ChainMock"), 0) , open_mocker(MOCKPP_PCHAR("open"), this) , read_mocker(MOCKPP_PCHAR("read"), this) , write_mocker(MOCKPP_PCHAR("write"), this) @@ -64,11 +64,11 @@ close_mocker.forward(); } - 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; + MOCKPP_NS::ChainableMockMethod<void, MOCKPP_STL::string> open_mocker; + MOCKPP_NS::ChainableMockMethod<MOCKPP_STL::string> read_mocker; + MOCKPP_NS::ChainableMockMethod<void, MOCKPP_STL::string> write_mocker; + MOCKPP_NS::ChainableMockMethod<void> close_mocker; + MOCKPP_NS::ChainableMockMethod<unsigned, unsigned> calculate_mocker; }; @@ -78,11 +78,11 @@ { ChainMock mock; - 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); + MOCKPP_NS::ChainableMockMethod<void, MOCKPP_STL::string> &open_chainer (mock.open_mocker); + MOCKPP_NS::ChainableMockMethod<MOCKPP_STL::string> &read_chainer (mock.read_mocker); + MOCKPP_NS::ChainableMockMethod<void, MOCKPP_STL::string> &write_chainer (mock.write_mocker); + MOCKPP_NS::ChainableMockMethod<void> &close_chainer (mock.close_mocker); + MOCKPP_NS::ChainableMockMethod<unsigned, unsigned> &calculate_chainer (mock.calculate_mocker); // Expectations for reading the file open_chainer.expects(once()) Index: basicmock.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/basicmock.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- basicmock.cpp 29 Dec 2005 19:29:51 -0000 1.9 +++ basicmock.cpp 15 Mar 2006 21:34:04 -0000 1.10 @@ -27,16 +27,16 @@ #include <exception> #include <iostream> -using namespace mockpp; +USING_NAMESPACE_MOCKPP class BasicMock : public Interface - , public mockpp::MockObject + , public MOCKPP_NS::MockObject { public: BasicMock() - : mockpp::MockObject(MOCKPP_PCHAR("BasicMock"), 0) + : MOCKPP_NS::MockObject(MOCKPP_PCHAR("BasicMock"), 0) , open_name(MOCKPP_PCHAR("BasicMock/open_name"), this) , close_counter(MOCKPP_PCHAR("BasicMock/close_counter"), this) , write_data(MOCKPP_PCHAR("BasicMock/write_data"), this) @@ -72,12 +72,12 @@ close_counter.inc(); } - mockpp::ExpectationList<MOCKPP_STL::string> open_name; - mockpp::ExpectationCounter close_counter; - mockpp::ExpectationList<MOCKPP_STL::string> write_data; - mockpp::ReturnObjectList<MOCKPP_STL::string> read_data; - mockpp::ReturnObjectList<unsigned> calculate_output; - mockpp::ConstraintList<unsigned > calculate_input; + MOCKPP_NS::ExpectationList<MOCKPP_STL::string> open_name; + MOCKPP_NS::ExpectationCounter close_counter; + MOCKPP_NS::ExpectationList<MOCKPP_STL::string> write_data; + MOCKPP_NS::ReturnObjectList<MOCKPP_STL::string> read_data; + MOCKPP_NS::ReturnObjectList<unsigned> calculate_output; + MOCKPP_NS::ConstraintList<unsigned > calculate_input; }; Index: chainmock.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/examples/tutorial/chainmock.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- chainmock.cpp 29 Dec 2005 19:29:51 -0000 1.14 +++ chainmock.cpp 15 Mar 2006 21:34:04 -0000 1.15 @@ -22,25 +22,25 @@ #include <exception> #include <iostream> -using namespace mockpp; +USING_NAMESPACE_MOCKPP -typedef mockpp::Invocation1<MOCKPP_STL::string> InvocationString; -typedef mockpp::Invocation1<unsigned> InvocationUInt; +typedef MOCKPP_NS::Invocation1<MOCKPP_STL::string> InvocationString; +typedef MOCKPP_NS::Invocation1<unsigned> InvocationUInt; /* -MOCKPP_PTI_IMPLEMENT(mockpp::Invocation0); +MOCKPP_PTI_IMPLEMENT(MOCKPP_NS::Invocation0); MOCKPP_PTI_IMPLEMENT(InvocationString); MOCKPP_PTI_IMPLEMENT(InvocationUInt); */ class ChainMock : public Interface - , public mockpp::ChainableMockObject + , public MOCKPP_NS::ChainableMockObject { public: ChainMock() - : mockpp::ChainableMockObject(MOCKPP_PCHAR("ChainMock"), 0) + : MOCKPP_NS::ChainableMockObject(MOCKPP_PCHAR("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) |