Reputation: 13569
I have following mock method:
MOCK_METHOD1(send, void(const std::vector<int>& data));
How to check if that method was called with a particular argument, for example std::vector<int> vec{1,2,3}
?
Upvotes: 1
Views: 2083
Reputation: 7002
According to gmock docs on container matchers, for the proposed use case, you could simply do:
EXPECT_CALL(mockObj, send(std::vector<int>{1,2,3}).Times(1);
Upvotes: 2
Reputation: 4153
Assuming that you mock object is named mockObj
, this is how to you would match the argument with the desired vector:
std::vector<int> dataToMatch{ 1, 2, 3 };
EXPECT_CALL(mockObj, send(ElementsAreArray(dataToMatch.cbegin(), dataToMatch.cend())))
.WillOnce(Return());
Upvotes: 1