How I make fun of an overloaded function with const / non

How do I make fun of the following code?

class ISomeClass
{
public:
   virtual ~ISomeClass() {} = 0;
   virtual const MyType & getType() const = 0;
   virtual MyType & getType() = 0;
};

I tried the following, but it does not work. Can you help me?

class MockSomeClass : public ISomeClass
{
public:
    using MyTypeConstRefType = const MyType&;
    using MyTypeRefType = MyType&;

public:
    MOCK_METHOD0(getType, MyTypeConstRefType(void) const);

    MOCK_METHOD0(getType, MyTypeRefType(void));
};
+4
source share
1 answer

They provide a separate set of macros for constmember functions ( "methods") MOCK_CONST_METHOD#. Therefore, in your case it will be:

MOCK_CONST_METHOD0(getType, MyTypeConstRefType());

The use is otherwise identical MOCK_METHOD#, using the name of the function in the first argument and the type of the function in the second.

+3
source

Source: https://habr.com/ru/post/1619325/


All Articles