eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.24k stars 173 forks source link

Get Invocation Count / Verify with Or #219

Open ConorMurphy21 opened 3 years ago

ConorMurphy21 commented 3 years ago

I'm trying to verify that one of the overloaded method signatures gets called. I don't care which one gets called. Is there a way I could do this with fakeit? ie Verify(Method(foo, bar) || Method(Foo, bar)).Twice(). Or if that doesn't exist is there a way to get the invocation count of a method so I can just add them together?

FranckRJ commented 1 year ago

There is no built-in way for that as far as I know, you can manually do it by mocking these functions with a Do and passing a lambda that increment a counter but I guess you were asking for a built-in solution.

malcolmdavey commented 1 year ago

Obviously the Do can be used, but an alternative could be adding a function that returns the number of invocations, then you could manually Assert etc. Not sure if there is a nicer syntactically sugary way to do this.