Search code examples
parameter-passinghippomocks

Hippomocks pointer argument - provide input, check output


I have a function that expects a buffer length input in a pointer argument, and then puts the number of the read bytes into that same argument as output. Now in my unit test I try to mock it with Hippomocks, and would like to check if the function was called with the correct input value, and at the same time, provide a different output value. How could I achieve this? Thanks!


Solution

  • Picking in my memory since I haven't used Hippomocks in a long time, I can't give the exact syntax, but that's what Hippomocks' Do() method is for.

    In Hippomocks' test suite you can find a usage example with a lambda expression: https://github.com/dascandy/hippomocks/blob/master/HippoMocksTest/test_do.cpp#L20.