【发布时间】:2020-08-21 02:43:56
【问题描述】:
class Parent
{
public:
int* x;
};
//is I am trying to make an object of type parent, it results: waiting for specifier after new *
class Child:public Parent
{
void Func()
{
<//DO SOMETHING>
}
};
//Unit test using mock
std::shared_pointer<Child> y =std::make_shared<Mock>();
//set_pointer(y);** //how this can be implemented
EXPECT_CALL(*(std::dynamic_pointer_cast<Mock>(y)).get(),Func()).Times(1);//this test is failed
【问题讨论】:
-
我不明白你在做什么。创建
Parent类型的对象有什么问题?set_pointer应该做什么?为什么你需要dynamic_pointer_cast而不是让y成为std::shared_ptr<Mock>类型? -
我正在尝试将 x 设置为 y 的值,并且在期望调用时收到 sgm 错误
标签: c++ unit-testing pointers inheritance googlemock