gmock - Mocking non-virtual method generating errors -


i'm trying hang of google mocks i've hit snag trying mock non-virtual methods. have socket class want mock. has non-virtual method called "write" takes arguments:

class socket { public:     int write(const unsigned char* buffer, size_t bufferlength) const; } 

so create mock class specified cook book:

class mocksocket { public:     mock_const_method0(write, int(const unsigned char* data, size_t datalength)); }; 

but doesn't compile. generates following errors:

error: size of array ‘this_method_does_not_take_0_arguments’ negative error: no matching function call ‘testing::internal::functionmocker<int ()(const unsigned char*, size_t)>::invoke()’ error: no matching function call ‘testing::internal::functionmocker<int ()(const unsigned char*, size_t)>::with()’ 

could tell me why??

thanks.

okay, didn't mix coffee strong enough morning. figured out problem. using wrong macro. works:

class mocksocket { public:     mock_const_method2(foo, int(const unsigned char* buffer, size_t len)); }; 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -