Код: Выделить всё
//required because some versions of gtest messes with extra commas in MOCK_METHOD
typedef std::pair KeyValueType;
class MockSUT : public SUT
{
public:
MOCK_METHOD(bool, foo, (const std::vector &data), (override));
MOCK_METHOD(bool, foo, (const std::string &key, const std::string& data), (override));
};
Код: Выделить всё
TEST_F(fixture, test)
{
...
std::shared_ptr mock = std::make_shared();
ON_CALL(..,..); //on call on another mock that succeds
ON_CALL(*mock.get(), foo(::testing::Matcher()))
.WillByDefault([&](const std::vector& data)-> bool{
EXPECT_TRUE(true);
return true;
});
}
Исходная функция вызывается следующим образом:
Код: Выделить всё
shared_pointer_castom->foo({
{
defined_char_array,
static_cast(someVal)
},
{
defined_car_array2,
static_cast(someOtherVal)
}]
});
Код: Выделить всё
template
class MatcherBase : private MatcherDescriberInterface {
public:
// Returns true if and only if the matcher matches x; also explains the
// match result to 'listener'.
bool MatchAndExplain(const T& x, MatchResultListener* listener) const {
GTEST_CHECK_(vtable_ != nullptr);
return vtable_->match_and_explain(*this, x, listener);
}
...
Подробнее здесь: https://stackoverflow.com/questions/790 ... nfunctions