저는 Google Mock을 처음 접했고이 코드로 손을 잡았습니다.이 링크도 확인했습니다. Google 모의 실제 함수 호출 수가 일치하지 않습니다. EXP30_CALL
Actual function call count doesn't match EXPECT_CALL(*mock, display())
하지만 적절한 입력을받을 수 없습니다.Base.cc
class Base
{
int val;
string msg;
public:
Base():val(0), msg("world"){}
virtual ~Base(){}
virtual void set(int x, string msg)
{
this->val = val;
this->msg = msg;
}
virtual void get()
{
cout << "val :" << this->val << endl;
cout << "msg :" << this->msg << endl;
}
};
class MockBase : public Base
{
public:
MOCK_METHOD0(get, void());
MOCK_METHOD2(set, void(int val, string msg));
};
Base_unittest.cc
int main(int argc, char * argv[])
{
std::cout << "in main" << endl;
::testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS();
}
TEST(Base, case1)
{
MockBase obj;
EXPECT_CALL(obj, get()).WillOnce(::testing::Return());
}
TEST(Base, case2)
{
MockBase obj;
EXPECT_CALL(obj, set(2,"hello")).WillOnce(::testing::Return());
}
나는 점점 오전 오류 :
그래서 도움을 주시기 바랍니다 및 초보자에 대한 자습서를 참조하십시오.Actual function call count doesn't match EXPECT_CALL(obj, get())...
Actual function call count doesn't match EXPECT_CALL(obj, set(2,"hello"))...