0

With the following class:

class Math {
public:
    static int Add(int a, int b) {
        return a + b;
    }

    static int Add(int a, int b, int c) {
        return a + b + c;
    }
};

How to use ExpectCallFuncOverload?

I try

#include <hippomock.h>

int main() {
    HippoMock::MockRepository mocks;
    mocks.ExpectCallFuncOverload(Math::Add).Return(5);

    Math::Add(2, 3);
    return 0;
}

gcc tells "call of overloaded 'RegisterExpect_...' is ambiguous"

How to tell Hippomock which overload we want to use? I don't find anything in the documentation

Thanks,

xibi
  • 101
  • 1
  • 8

1 Answers1

0

I found it!

Use a cast to determine the function to use

mocks.ExpectCallFuncOverload((int (*)(int, int))Math::Add).Return(5);
xibi
  • 101
  • 1
  • 8