2 years ago
#64719

Son_Nguyen
How to mock method with default parameter in Google Mock C++?
How to mock a method with optional parameter in Google Mock? For example: I try this, but it does not work:
template <typename T>
class A
{
public:
virtual void set_enable(const int test, const bool enabled = true ) const;
};
template <typename T>
class MockA : public A<T>
{
MOCK_CONST_METHOD2_T( set_enable, void(const int test, const bool enabled ) );
void set_enable(const int test /*, const bool enabled = true*/ ) const
{
set_enable( test, true);
}
};
Then call:
MockA mockA;
EXPECT_CALL(mockA, set_enable(_,true)).Times(Exactly(1));
When I run test, it show "Segmentation fault"
c++
mocking
googletest
googlemock
0 Answers
Your Answer