mercredi 31 juillet 2019

Gmock - strict mock and unique ptr - how to pass mock to impl

Here is an example code:

class Interface
{
public:
    virtual ~Interface(){}
    virtual void Start() = 0;
};

class MockInterface: public Interface
{
public:
    MOCK_METHOD0(Start, void());
};

class T
{
public:
    T(std::unique_ptr<Interface>& impl): impl_(impl){}
private:
    std::unique_ptr<Interface>& impl_;
};

I would like to create a strict mock but I'm not sure how to construct it as unique ptr and then pass to T constructor.

Aucun commentaire:

Enregistrer un commentaire