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}
?
根据容器匹配器上的gmock文档,对于建议的用例,您可以简单地执行:
EXPECT_CALL(mockObj, send(std::vector<int>{1,2,3}).Times(1);
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());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.