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>
diff --git a/subsys/testsuite/ztest/include/ztest_assert.h b/subsys/testsuite/ztest/include/ztest_assert.h
index 1b078e4..e440015 100644
--- a/subsys/testsuite/ztest/include/ztest_assert.h
+++ b/subsys/testsuite/ztest/include/ztest_assert.h
@@ -211,6 +211,20 @@
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
*
* This macro calls the final memory comparison assertion macro.