Can Google Mock a method with a smart pointer return type?

前端 未结 5 1320
死守一世寂寞
死守一世寂寞 2020-11-28 23:32

I have a factory that returns a smart pointer. Regardless of what smart pointer I use, I can\'t get Google Mock to mock the factory method.

The mock object is the im

5条回答
  •  生来不讨喜
    2020-11-29 00:01

    in the mock class put same as you want

    MOCK_METHOD0(Create, std::unique_ptr());


    and in the test as below

    EXPECT_CALL(, Create())
    .WillOnce([]()->std::unique_ptr{
        return std::make_unique();
    });
    

    if vs 2010 not support for lambda, you can use a functor

提交回复
热议问题