Pergunta

In the mocking framework Hippomocks it is possible to check the passed arguments within an expectation. For example:

void Class::Method(int arg1);
...
m_mockRepository_p->ExpectCall(someObject_p, Class::Method).With(1);

Is there a possibility to check only some of the passed arguments? What should I write instead of ??? in the following code?

void Class::Method(int arg1, char* buffer_p);
...
m_mockRepository_p->ExpectCall(someObject_p, Class::Method).With(1,???);

For your information: The use case is that someObjet_p creates internally a buffer to read data in it and passes it to Class::Method. Firstly I don't care in which buffer someObject_p would like the data to put in. Secondly I don't have access to the internals of someObject_p to pass it to With() - which is quite reasonable.

Note: I've tagged the question as C++ as I make use of ExpectCall but I'd guess the same would apply to ExpectCallFunc for flat functions.

Second note: Hippomocks provides methods for expectations named "Match()", "getArgs()", "assignArgs()" and "matchesArgs()" but neither did I find any documentation on it nor do I know whether they are intended to be used (for my use case) or not.

Foi útil?

Solução

Pass in a Don't-Care as that parameter:

m_mockRepository_p->ExpectCall(someObject_p, Class::Method).With(1, _);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top