testsuite: ztest: Add zassert_within macro
Added macro to test value against another value with accepted delta. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
44739f4427
commit
7a2d025bce
1 changed files with 13 additions and 0 deletions
|
@ -168,6 +168,19 @@ static inline void z_zassert(int cond,
|
|||
zassert((void *)(a) == (void *)(b), #a " not equal to " #b, \
|
||||
msg, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Assert that @a a is within @a b with delta @a d
|
||||
*
|
||||
* @param a Value to compare
|
||||
* @param b Value to compare
|
||||
* @param d Delta
|
||||
* @param msg Optional message to print if the assertion fails
|
||||
*/
|
||||
#define zassert_within(a, b, d, msg, ...) \
|
||||
zassert(((a) > ((b) - (d))) && ((a) < ((b) + (d))), \
|
||||
#a " not within " #b " +/- " #d, \
|
||||
msg, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Assert that 2 memory buffers have the same contents
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue