Rakesh navaneethakrishnan
unread,Feb 3, 2013, 3:50:57 AM2/3/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to googl...@googlegroups.com
Actually my project is C Project and i am declaring mock object in heap, but declared as a global variable.but still i got this error.
below one is my coed snippet. i dont think i can delete this object and it is not giving any memory leakage. Any idea guys?
//Mock class
class system_mock{
public:
MOCK_METHOD2(open, int(const char *filename, int flags));
MOCK_METHOD3(ioctl, int(int filedes, long unsigned int command,unsigned char* p));
MOCK_METHOD3(ioctl, int(int filedes, long unsigned int command, spi_ioc_transfer* mesg));
};
system_mock mock;
//System call whihc have been mocked
int open (const char *filename, int flags)
{
return mock.open(filename, flags);
}
int ioctl (int filedes, long unsigned int command,unsigned char* p){
return mock.ioctl(filedes,command,p);
}
int ioctl (int filedes, long unsigned int command, spi_ioc_transfer* mesg)
{
return mock.ioctl(filedes,command,mesg);
}
TEST(configspi, spi_init) {
EXPECT_CALL(mock,open(An<const char*>(),_))
.WillRepeatedly(Return(1));
EXPECT_CALL(mock,ioctl(An<int>(),An<unsigned long int>(),An<unsigned char*>()))
.Times(18)
.WillRepeatedly(Return(0));
EXPECT_EQ(0, spi_init());
}