0

I have a function that is configured to be called in a certain frequency (let's say every second). I need to implement a test that checks whether the function meets this requirement.

I was hoping to have any qualifier like .Frequency(, ) but I could not find it. So I would have:

EXPECT_CALL(my_obj, obj_function()).Frequency(900, 1100);

How can I validate this requirement by using Google Test?

1 Answers1

0

Your question isn't exactly the same as this, but it is similar. I think you can do something like:

StartTimer()
EXPECT_CALL(my_obj, obj_function());
EndTimer();
ASSERT_TRUE(elapsedTime() >= 0.9);
ASSERT_TRUE(elapsedTime() <= 1.1);

Either in a loop, or repeated the suitable amount of time - presumably you don't want to run this for hours, but a handful of calls...

Mats Petersson
  • 126,704
  • 14
  • 140
  • 227