Update of /cvsroot/mocklib//cppmocklib/src/mock
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6515/src/mock
Added Files:
Behavior.h CalledMethod.cpp MockSuperclass.cpp
MockSuperclass.h MockObject.h CalledMethod.h basic.h
Log Message:
package refactor
--- NEW FILE: basic.h ---
#ifndef BASIC_H_
#define BASIC_H_
#endif /*BASIC_H_*/
using namespace std;
class NullType;
class EmptyType {};
template <class T,class U>
struct Typelist{
typedef T Head;
typedef U Tail;
};
#define TYPELIST_1(T1) Typelist<T1,NullType>
#define TYPELIST_2(T1,T2) Typelist<T1,TYPELIST_1(T2) >
#define TYPELIST_3(T1,T2,T3) Typelist<T1,TYPELIST_2(T1,T2) >
--- NEW FILE: MockSuperclass.cpp ---
using namespace std;
#include"MockSuperclass.h"
string MockObject::NONE="No method should have been called";
string MockObject::ANY="Any method";
void MockSuperclass::removeIgnore(string method){
};
CalledMethod & MockSuperclass::expect(string method){
return (calledMethods.at(0));
};
MockSuperclass::vector_CalledMethod * MockSuperclass::expect(string method[]){
return &calledMethods;
};
void MockSuperclass::methodCalled(string methodName, ...){
va_list argus;
CalledMethod *pCalledMethod = new CalledMethod();
pCalledMethod->setMethod(methodName);
va_start(argus, methodName);
};
--- NEW FILE: CalledMethod.cpp ---
#include "CalledMethod.h"
--- NEW FILE: CalledMethod.h ---
#ifndef CALLEDMETHOD_H_
#define CALLEDMETHOD_H_
#include<stdarg.h>
#include <string>
#include "basic.h"
class CalledMethod{
private :
string method;
va_list params;
exception howItWasCalled;
public :
string getMethod(){
return method;
};
va_list getParams(){return params;};
exception getHowItWasCalled(){return howItWasCalled;};
void setMethod(string strMethod){method=strMethod;};
void setParams(va_list valist){params=valist;};
void setHowItWasCalled(exception argu){howItWasCalled=argu;};
public :
};
#endif /*CALLEDMETHOD_H_*/
--- NEW FILE: MockSuperclass.h ---
#ifndef MOCKSUPERCLASS_H_
#define MOCKSUPERCLASS_H_
#include<vector>
#include "MockObject.h"
#include<stdarg.h>
class MockSuperclass : public MockObject{
public:
void removeIgnore(string method);
CalledMethod & expect(string method);
MockSuperclass::vector_CalledMethod * expect(string method[]);
void methodCalled(string methodName, ...);
private:
vector_CalledMethod calledMethods;
};
#endif /*MOCKSUPERCLASS_H_*/
--- NEW FILE: MockObject.h ---
#ifndef MOCKOBJECT_H_
#define MOCKOBJECT_H_
using namespace std;
#include <string>
#include <vector>
#include "CalledMethod.h"
#include "Behavior.h"
class MockObject{
public :
static string NONE;
static string ANY;
public :
typedef vector<CalledMethod> vector_CalledMethod;
public:
virtual CalledMethod & expect(string method)=0;
virtual vector_CalledMethod * expect(string methods[])=0;
//virtual void setDefaultReturnValue(string method,T object)=0;
// virtual void setDefaultBehavior(string method,T object)=0;
//this method should have different type arguments and numbers is not exactly confirmed
//so argus should use typelist
// virtual void setDefaultBehavior(string method, Behavior b, T argus[])=0;
// virtual void addThrowException(string method, exception e)=0;
// virtual void addReturnValue(string method, T obj)=0;
// virtual void addReturnValue(string method, T obj[])=0;
// virtual void addIgnore(string method)=0;
virtual void removeIgnore(string method)=0;
// virtual void setExpectTimeout(int timeout)=0;
// virtual int getExpectTimeout()=0;
};
#endif /*MOCKOBJECT_H_*/
--- NEW FILE: Behavior.h ---
#ifndef BEHAVIOR_H_
#define BEHAVIOR_H_
class Behavior{
};
#endif /*BEHAVIOR_H_*/
|