From 0698835633f1c6619a26d195745660802a29d4a1 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Fri, 30 Oct 2020 11:36:02 +0100 Subject: [PATCH] Added path_to_fail to mocking_utils in rcl Signed-off-by: ahcorde --- rcl/test/mocking_utils/patch.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rcl/test/mocking_utils/patch.hpp b/rcl/test/mocking_utils/patch.hpp index d170c7f..eeae201 100644 --- a/rcl/test/mocking_utils/patch.hpp +++ b/rcl/test/mocking_utils/patch.hpp @@ -354,6 +354,14 @@ auto make_patch(const std::string & target, std::function proxy) #define patch_and_return(scope, function, return_code) \ patch(scope, function, [&](auto && ...) {return return_code;}) +/// Patch a `function` to always yield a given `return_code` in a given `scope`. +#define patch_to_fail(scope, function, error_message, return_code) \ + patch( \ + scope, function, [&](auto && ...) { \ + RCUTILS_SET_ERROR_MSG(error_message); \ + return return_code; \ + }) + /// Patch a `function` to execute normally but always yield a given `return_code` /// in a given `scope`. #define inject_on_return(scope, function, return_code) \