I have a small class:
struct Command
{
uint8_t cmdId;
uint8_t len;
uint8_t payload[MAX_PAYLOAD];
};
And I want to check only the first two elements of the payload using googlemock expectations. I cannot use ElementsAreArray because it checks that the payload lengths and expectations are the same. So far I have an expectation that looks like this:
Command cmd;
cmd.cmdId = 0xD3;
cmd.len = 2;
cmd.payload[0] = 'm';
cmd.payload[1] = 'l';
EXPECT_CALL(mockQueue,
sendFromIsr(Pointee(AllOf(
Field(&Command::cmdId, Eq(0xD3)),
Field(&Command::len, Eq(2)),
//Field(&BirdCommand::payload, ElementsAreArray(cmd.payload, 2)) !<-- Doesn't work
))))
.WillOnce(Return(true));
Any ideas? The mock class is as follows:
template <typename T>
class MockQueue : public Queue<T>
{
public:
MOCK_METHOD1_T(sendFromIsr, bool(T &item));
};
source
share