Is there a way to store the data from an vector reference to a MOCK_METHOD?
I have following mocked interface:
MOCK_METHOD(bool, SetData, (const std::vector<uint8_t>& data), (override));
And I would like to test the data that is sent to this mock method, ex.
std::vector<uint8_t> test_data;
EXPECT_CALL(testClass, SetData(_)).SaveArg<0>(&test_data);
EXPECT_EQ(test_data[0], 42);
It can be done, see below. Note though, that matchers, even the more complex ones, are oftentimes considered the cleaner solution anyway.
https://godbolt.org/z/4MrEPvaa3