From 5f7aeeea06a3954f307e41f2ba149cea10aa038b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 17 Dec 2018 23:26:52 +0100 Subject: [PATCH] New test macro TEST_EQUAL TEST_EQUAL(expr1, expr2) is just TEST_ASSERT((expr1) == (expr2)) for now, but in the future I hope that it will print out the differing values. --- tests/suites/helpers.function | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/suites/helpers.function b/tests/suites/helpers.function index 316c06e31..da843b2b3 100644 --- a/tests/suites/helpers.function +++ b/tests/suites/helpers.function @@ -90,13 +90,23 @@ typedef struct data_tag } \ } while( 0 ) +/** Evaluate two expressions and fail the test case if they have different + * values. + * + * \param expr1 An expression to evaluate. + * \param expr2 The expected value of \p expr1. This can be any + * expression, but it is typically a constant. + */ +#define TEST_EQUAL( expr1, expr2 ) \ + TEST_ASSERT( ( expr1 ) == ( expr2 ) ) + /** Evaluate an expression and fail the test case if it returns an error. * * \param expr The expression to evaluate. This is typically a call * to a \c psa_xxx function that returns a value of type * #psa_status_t. */ -#define PSA_ASSERT( expr ) TEST_ASSERT( ( expr ) == PSA_SUCCESS ) +#define PSA_ASSERT( expr ) TEST_EQUAL( ( expr ), PSA_SUCCESS ) /** Allocate memory dynamically and fail the test case if this fails. *