ztest: Add zassert_between_inclusive macro

Added macro to test that a value falls within a defined range, including
the provided end points.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2022-03-26 09:03:02 +10:00 committed by Carles Cufí
commit f2b8a9918f

View file

@ -210,6 +210,20 @@ static inline bool z_zassert(bool cond,
#a " not within " #b " +/- " #d, \
msg, ##__VA_ARGS__)
/**
* @brief Assert that @a a is greater than or equal to @a l and less
* than or equal to @a u
*
* @param a Value to compare
* @param l Lower limit
* @param u Upper limit
* @param msg Optional message to print if the assertion fails
*/
#define zassert_between_inclusive(a, l, u, msg, ...) \
zassert(((a) >= (l)) && ((a) <= (u)), \
#a " not between " #l " and " #u " inclusive", \
msg, ##__VA_ARGS__)
/**
* @brief Assert that 2 memory buffers have the same contents
*