Google Mocks のコツをつかもうとしていますが、非仮想メソッドをモックしようとして問題が発生しました。モックしたい Socket クラスがあります。引数を取る「書き込み」と呼ばれる非仮想メソッドがあります。
class Socket {
public:
int write(const unsigned char* buffer, size_t bufferLength) const;
}
そこで、指定されたクック ブックとして Mock クラスを作成します。
class MockSocket {
public:
MOCK_CONST_METHOD0(write, int(const unsigned char* data, size_t dataLength));
};
しかし、これはコンパイルされません。次のエラーが生成されます。
error: size of array ‘this_method_does_not_take_0_arguments’ is negative
error: no matching function for call to ‘testing::internal::FunctionMocker<int ()(const unsigned char*, size_t)>::Invoke()’
error: no matching function for call to ‘testing::internal::FunctionMocker<int ()(const unsigned char*, size_t)>::With()’
誰かが理由を教えてもらえますか??
ありがとう。