[Mockpp-commits] mockpp/mockpp VisitableMockMethod.h,1.5,1.6
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-10-19 20:14:35
|
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14711/mockpp Modified Files: VisitableMockMethod.h Log Message: g++ 4.0 warnings Index: VisitableMockMethod.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/VisitableMockMethod.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- VisitableMockMethod.h 17 Oct 2005 19:15:09 -0000 1.5 +++ VisitableMockMethod.h 19 Oct 2005 20:14:27 -0000 1.6 @@ -56,7 +56,7 @@ //------------------------------------------------------------- template <class VMM> - friend class ControllerFor : public VisitableMockObject::Controller + class ControllerFor : public VisitableMockObject::Controller { public: @@ -131,6 +131,9 @@ VisitableMockObject *object; }; + template <class VMM> + friend class ControllerFor; + private: VisitableMockObject *visitable; @@ -141,44 +144,49 @@ }; -#ifdef MOCKPP_XXX - ////////////////////////////////////////////////////////////////////////////////////////////// -template <typename R, const char* Name> -class VisitableMockMethod0Base : public VisitableMockMethodBase +#ifdef MOCKPP_XXX + +template <typename R> +class VisitableMockReturningMethodBase : public VisitableMockMethodBase { public: /** Constructs the mock object. + * @param name the method name to mock * @param parent parent Visitable mock object */ - VisitableMockMethod0Base(VisitableMockObject *parent) - : VisitableMockMethodBase(Name, parent) - , returnValues(getMethodName() + MOCKPP_PCHAR("/returnValues") + VisitableMockReturningMethodBase(const String &name, VisitableMockObject *parent) + : VisitableMockMethodBase(name, parent) + , returnValues(getMethodName() + MOCKPP_PCHAR("/returnValues")) {} - friend class ControllerFor : public VisitableMockMethodBase::ControllerFor<VisitableMockMethod0Base> + class ControllerFor : public VisitableMockMethodBase::ControllerFor<VisitableMockMethodBase> { - typedef VisitableMockMethodBase::ControllerFor<VisitableMockMethod0Base> Inherited; + typedef VisitableMockMethodBase::ControllerFor<VisitableMockReturningMethodBase<R> > Inherited; public: + ControllerFor (VisitableMockReturningMethodBase<R> *meth) + : Inherited(meth) + { + } + void setDefaultReturnValue(const R &rv) { MOCKPP_ASSERT_FALSE(object->isActivated()); - object->haveDefaultReturnValue = true; - object->defaultReturnValue = rv; + method->haveDefaultReturnValue = true; + method->defaultReturnValue = rv; } virtual void reset() { Inherited::reset(); - VisitableMockMethodBase::ControllerFor<VisitableMockMethod0Base>::reset(); - object->haveDefaultReturnValue = false; - object->DefaultReturnValueUsed = false; + method->haveDefaultReturnValue = false; + method->defaultReturnValueUsed = false; returnValues.clear(); } @@ -189,7 +197,7 @@ { String fmt = mockpp_i18n(MOCKPP_PCHAR("%1 is unused.")); fmt << method->getMethodName() + MOCKPP_PCHAR("/defaultReturnValueUsed"); - MOCKPP_ASSERT_TRUE_MESSAGE(fmt, object->defaultReturnValueUsed); + MOCKPP_ASSERT_TRUE_MESSAGE(fmt, method->defaultReturnValueUsed); } returnvalues.verify(); @@ -197,40 +205,50 @@ }; + friend class ControllerFor; + protected: mutable ReturnObjectList<R> returnValues; bool haveDefaultReturnValue; mutable bool defaultReturnValueUsed; R defaultReturnValue; -} +}; -template <const char* Name> -class VisitableMockMethod0Base<void, const char*> : public VisitableMockMethodBase +template <> +class VisitableMockReturningMethodBase<void> : public VisitableMockMethodBase { public: /** Constructs the mock object. + * @param name the method name to mock * @param parent parent Visitable mock object */ - VisitableMockMethod0Base(VisitableMockObject *parent) - : VisitableMockMethodBase(Name, parent) + VisitableMockReturningMethodBase(const String &name, VisitableMockObject *parent) + : VisitableMockMethodBase(name, parent) {} - friend class ControllerFor : public ControllerFor<VisitableMockMethod0Base> + friend class ControllerFor : public VisitableMockMethodBase::ControllerFor<VisitableMockMethodBase> { + typedef VisitableMockMethodBase::ControllerFor<VisitableMockMethodBase> Inherited; + public: + ControllerFor (VisitableMockReturningMethodBase<void> *meth) + : Inherited(meth) + { + } }; -} +}; ////////////////////////////////////////////////////////////////////////////////////////////// + template <typename R, typename P1> -class VisitableMockMethod1 : public VisitableMockMethod0Base<R> +class VisitableMockMethod1 : public VisitableMockReturningMethodBase<R> { public: @@ -239,7 +257,7 @@ * @param parent parent Visitable mock object */ VisitableMockMethod1(const String &name, VisitableMockObject *parent = 0) - : VisitableMockMethod0Base<R>(name, parent) + : VisitableMockReturningMethodBase<R>(name, parent) {} R forward(const P1 ¶m1) const @@ -300,7 +318,7 @@ Parameter1.addExpected(param1); } - friend class ControllerFor : public VisitableMockMethod0Base<R>::ControllerFor + friend class ControllerFor : public VisitableMockReturningMethodBase<R>::ControllerFor { public: |