Can Google Mock A Method With A Smart Pointer Return Type?
Answer : A feasible workaround for google mock framework's problems with non (const) copyable function arguments and retun values is to use proxy mock methods. Suppose you have the following interface definition (if it's good style to use std::unique_ptr in this way seems to be more or less a philosophical question, I personally like it to enforce transfer of ownership): class IFooInterface { public: virtual void nonCopyableParam(std::unique_ptr<IMyObjectThing> uPtr) = 0; virtual std::unique_ptr<IMyObjectThing> nonCopyableReturn() = 0; virtual ~IFooInterface() {} }; The appropriate mock class could be defined like this: class FooInterfaceMock : public IFooInterface { public: FooInterfaceMock() {} virtual ~FooInterfaceMock() {} virtual void nonCopyableParam(std::unique_ptr<IMyObjectThing> uPtr) { nonCopyableParamProxy(uPtr.get()); } virtual std::unique_ptr<IMyObjectThing> nonCopyableReturn() { r...