How to create a mock class with operator[]?

Viewed 3244

I am having a class with operator[], like this :

class Base
{
  public:
    virtual ~Base(){}
    virtual const int & operator[]( const unsigned int index ) const = 0;
};

How can I create a mock class using google mock framework for this method?

I tried this :

class MockBase : public Base
{
public:
  MOCK_CONST_METHOD1( operator[],
                      const int& ( const unsigned int )
                      );
};

but that produces next errors :

error: pasting "]" and "_" does not give a valid preprocessing token
error: pasting "]" and "_" does not give a valid preprocessing token
error: pasting "]" and "_" does not give a valid preprocessing token
error: pasting "]" and "_" does not give a valid preprocessing token
1 Answers
Related