ztest: fix z_assert_within() bounds

zassert_within should also compare on equality instead
of only greater/lower.
example:
zassert_within(1,1,0); // should return true
zassert_within(1,2,1); // should return true

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
This commit is contained in:
Alexander Wachter 2021-02-14 19:56:23 +01:00 committed by Anas Nashif
commit 0c1877a999

View file

@ -190,7 +190,7 @@ static inline void z_zassert(bool cond,
* @param msg Optional message to print if the assertion fails
*/
#define zassert_within(a, b, d, msg, ...) \
zassert(((a) > ((b) - (d))) && ((a) < ((b) + (d))), \
zassert(((a) >= ((b) - (d))) && ((a) <= ((b) + (d))), \
#a " not within " #b " +/- " #d, \
msg, ##__VA_ARGS__)