Skip to content

Commit 8791a2b

Browse files
author
David Saada
committed
Add a Unity macro to assert on platform error code difference
1 parent 0e6eac5 commit 8791a2b

File tree

1 file changed

+10
-0
lines changed
  • features/frameworks/unity/unity

1 file changed

+10
-0
lines changed

features/frameworks/unity/unity/unity.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern "C"
2424
#define UNITY_FLOAT_VERBOSE
2525

2626
#include "unity_internals.h"
27+
#include "mbed_error.h"
2728

2829
void setUp(void);
2930
void tearDown(void);
@@ -294,6 +295,15 @@ void tearDown(void);
294295
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message))
295296
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message))
296297

298+
299+
/*-------------------------------------------------------
300+
* Error code checking
301+
*-------------------------------------------------------*/
302+
// Use these to check whether error code equals what we expect.
303+
// Only display error code (without other information)
304+
#define TEST_ASSERT_EQUAL_ERROR_CODE(expected, actual) TEST_ASSERT_EQUAL(expected & MBED_ERROR_STATUS_CODE_MASK, actual & MBED_ERROR_STATUS_CODE_MASK)
305+
#define TEST_ASSERT_EQUAL_ERROR_CODE_MESSAGE(expected, actual, message) TEST_ASSERT_EQUAL_MESSAGE(expected & MBED_ERROR_STATUS_CODE_MASK, actual & MBED_ERROR_STATUS_CODE_MASK)
306+
297307
/*-------------------------------------------------------
298308
* Test skipping
299309
*-------------------------------------------------------*/

0 commit comments

Comments
 (0)