GoogleMock: Expect either of two method calls

后端 未结 1 1914
孤街浪徒
孤街浪徒 2021-01-19 02:42

I have a class Foo that references multiple other objects of type IBar. The class has a method fun that needs to invoke method f

1条回答
  •  一整个雨季
    2021-01-19 03:15

    This can be achieved using check points:

    using ::testing::MockFunction;
    
    MockFunction check_point;
    EXPECT_CALL(*bar1, frob())
        .Times(AtMost(1))
        .WillRepeatedly(
            InvokeWithoutArgs(&check_point, &MockFunction::Call);
    EXPECT_CALL(*bar2, frob())
        .Times(AtMost(1))
        .WillRepeatedly(
            InvokeWithoutArgs(&check_point, &MockFunction::Call);
    EXPECT_CALL(check_point, Call())
        .Times(Exactly(1));
    

    0 讨论(0)
提交回复
热议问题