How can I make google test fail if google mocked method is called more than expected times?
Here is the example:
class MockIO : iIO
{
MOCK_METHOD1(IO_Read, void (uint8_t));
};
TEST(case, test)
{
MockIO io;
EXPECT_CALL(io, IO_Read(0x01)).Times(10);
for (i=0; i<20; i++)
io.IO_Read(0x01);
}
As I understand I should try
EXPECT_CALL(io, IO_Read(0x01)).Times(10).Throw(exception);
But in embedded projects exceptions not used.
Any ideas?
I think you should use strict mocks for your test.
When using a Strictmock, not expected calls cause a testfailure.
http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks