GoogleMock: Expect either of two method calls

后端 未结 1 1899
孤街浪徒
孤街浪徒 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<void()> check_point;
    EXPECT_CALL(*bar1, frob())
        .Times(AtMost(1))
        .WillRepeatedly(
            InvokeWithoutArgs(&check_point, &MockFunction<void()>::Call);
    EXPECT_CALL(*bar2, frob())
        .Times(AtMost(1))
        .WillRepeatedly(
            InvokeWithoutArgs(&check_point, &MockFunction<void()>::Call);
    EXPECT_CALL(check_point, Call())
        .Times(Exactly(1));
    
    0 讨论(0)
提交回复
热议问题