Google Mock中是否有宏来通过在宏替换中附加override
关键字,以确保对f()
签名的编译时检查:
struct I
{
virtual void f() = 0;
};
struct MockI
{
MOCK_METHOD0(f, void()); // this will define another function if f signature changes
// leading to weird runtime test failures
};
noexcept
而不是override
,但答案是相同的。 - Yksisarvinen