Код: Выделить всё
#include
#include
class my_mock {
public:
MOCK_METHOD(void, foo, ());
MOCK_METHOD(void, bar, ());
MOCK_METHOD(void, baz, ());
MOCK_METHOD(void, log, ());
};
class my_test : public testing::TestWithParam {};
void test(my_mock& mock, uint32_t mask) {
if (mask & 1) mock.log();
mock.foo();
if (mask & 2) mock.log();
mock.bar();
if (mask & 4) mock.log();
mock.baz();
if (mask & 8) mock.log();
}
TEST_P(my_test, my_test) {
testing::StrictMock mock{};
testing::InSequence seq{};
testing::Sequence unseq{};
EXPECT_CALL(mock, log).Times(testing::AnyNumber()).InSequence(unseq);
EXPECT_CALL(mock, foo).Times(1);
EXPECT_CALL(mock, bar).Times(1);
EXPECT_CALL(mock, baz).Times(1);
test(mock, GetParam());
}
INSTANTIATE_TEST_SUITE_P(
my_test, my_test, testing::Range(0, 16)
);
Подробнее здесь: https://stackoverflow.com/questions/794 ... nsequenced