1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include <string>
#include "hippomocks.h"
#include "Framework.h"
class IInParam {
public:
virtual ~IInParam() {}
virtual void a(const std::string& in) = 0;
virtual void b(std::string* in) = 0;
virtual void c(const char* in) = 0;
};
TEST (checkInParamsAreFilledIn_ConstChar)
{
MockRepository mocks;
IInParam *iamock = mocks.Mock<IInParam>();
std::string teststring;
mocks.ExpectCall(iamock, IInParam::a).With(In(teststring));
iamock->a("Hello World");
CHECK(teststring == "Hello World");
}
TEST (checkInParamsAreFilledIn_String)
{
MockRepository mocks;
IInParam *iamock = mocks.Mock<IInParam>();
std::string teststring;
mocks.ExpectCall(iamock, IInParam::a).With(In(teststring));
std::string in("Hello World");
iamock->a(in);
CHECK(teststring == in);
}
TEST (checkInParamsAreFilledIn_PointerToString)
{
MockRepository mocks;
IInParam *iamock = mocks.Mock<IInParam>();
std::string* teststring = NULL;
mocks.ExpectCall(iamock, IInParam::b).With(In(teststring));
std::string in("Hello World");
iamock->b(&in);
CHECK(teststring == &in);
}
TEST (checkInParamsAreFilledIn_Char)
{
MockRepository mocks;
IInParam *iamock = mocks.Mock<IInParam>();
const char* teststring = NULL;
mocks.ExpectCall(iamock, IInParam::c).With(In(teststring));
const char* in = "Hello World";
iamock->c(in);
CHECK(strcmp(teststring, in) == 0);
}
|