diff --git a/tests/unit/test_util.h b/tests/unit/test_util.h index 0f04da359..112641959 100644 --- a/tests/unit/test_util.h +++ b/tests/unit/test_util.h @@ -39,24 +39,40 @@ extern "C" { // Enable main functions #define ENABLE_TEST_MAIN -#define SuccessOrQuit(ERR, MSG) \ - do \ - { \ - if ((ERR) != OT_ERROR_NONE) \ - { \ - fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, MSG); \ - exit(-1); \ - } \ +/** + * This macro verifies a given error status to be successful (compared against value zero (0)), otherwise, it emits a + * given error messages and exits the program. + * + * @param[in] aStatus A scalar error status to be evaluated against zero (0). + * @param[in] aMessage A message (text string) to print on failure. + * + */ +#define SuccessOrQuit(aStatus, aMessage) \ + do \ + { \ + if ((aStatus) != 0) \ + { \ + fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, aMessage); \ + exit(-1); \ + } \ } while (false) -#define VerifyOrQuit(TST, MSG) \ - do \ - { \ - if (!(TST)) \ - { \ - fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, MSG); \ - exit(-1); \ - } \ +/** + * This macro verifies that a given boolean condition is true, otherwise, it emits a given error message and exits the + * program. + * + * @param[in] aCondition A Boolean expression to be evaluated. + * @param[in] aMessage A message (text string) to print on failure. + * + */ +#define VerifyOrQuit(aCondition, aMessage) \ + do \ + { \ + if (!(aCondition)) \ + { \ + fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, aMessage); \ + exit(-1); \ + } \ } while (false) //#define CompileTimeAssert(COND, MSG) typedef char __C_ASSERT__[(COND)?1:-1]