SECTION("test async function") {
std::condition_variable cv;
std::mutex cvMutex;
REQUIRE_CALL(myMock, call_async())
.LR_SIDE_EFFECT(cv.notify_all());
// wrapper contains an instance of the mock which is called on the other side of an RPC
wrapper.call_async();
// In order to prevent timing out the REQUIRE_CALL, I need to wait for the call to end before the block exits.
std::unique_lock<std::mutex> lock(cvMutex);
// specify a timeout of 1s. This normally takes less than 1s during a successful test
REQUIRE(cv.wait_for(lock, 1s) == std::cv_status::no_timeout);
}
I would love a way to wrap this very verbose functionality. Maybe like this:
SECTION("test async function") {
REQUIRE_CALL(myMock, call_async())
.ASYNC_TIMEOUT(1s);
wrapper.call_async();
// could also wrap the call in a macro if neccecary...
}
considering the following code:
I would love a way to wrap this very verbose functionality. Maybe like this: