I want to mock a method with the declaration A::B X(void)
. The definition is something as follows.
class A {
class B;
virtual B X() = 0;
};
class A::B {
public:
auto_ptr<int> something;
};
My mock class, following this, is quite standard.
class mA : public A
{
public:
MOCK_METHOD0(X, A::B());
};
Compiled, however, this gives me this weirdo error, and I haven't been able to track it down. What is wrong with this?
In member function ‘virtual A::B mA::X()’:
...: error: no matching function for call to ‘A::B::B(A::B)’
...: note: candidates are: A::B::B()
...: A::B::B(A::B&)
Update I have found a failing code sample to demonstrate this.
#include <gmock/gmock.h>
#include <memory>
using std::auto_ptr;
class thing {
public:
class result;
virtual result accessor () = 0;
};
class thing::result {
auto_ptr<int> x; // If this just "int", error goes away.
};
namespace mock {
class thing : ::thing {
public:
MOCK_METHOD0 ( accessor, result() );
};
}