summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-01-13 20:09:51 +0700
committerhathach <[email protected]>2013-01-13 20:09:51 +0700
commitbeb20b975bb1a1871598bb1014a872fdd4aded6f (patch)
tree4421b169b7921518c7e97f7e33960fb1ae4144bc /tinyusb
parent1deac989696fc216acb4dd1208dab8991e886c6c (diff)
add ASSERT_INT_WITHIN and its test code
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/common/assertion.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h
index 935b99522..26dad566a 100644
--- a/tinyusb/common/assertion.h
+++ b/tinyusb/common/assertion.h
@@ -109,9 +109,18 @@ extern "C"
#define ASSERT_INT(...) ASSERT_INT_EQUAL(__VA_ARGS__)
#define ASSERT_INT_EQUAL(expected, actual, error) \
- ASSERT_DEFINE( uint32_t exp = (expected); uint32_t act = (actual), exp==act, error, "expected %d, actual %d", exp, act)
+ ASSERT_DEFINE(\
+ uint32_t exp = (expected); uint32_t act = (actual),\
+ exp==act,\
+ error,\
+ "expected %d, actual %d", exp, act)
-#define ASSERT_INT_WITHIN(lower, upper, actual)
+#define ASSERT_INT_WITHIN(lower, upper, actual, error) \
+ ASSERT_DEFINE(\
+ uint32_t low = (lower); uint32_t up = (upper); uint32_t act = (actual),\
+ (low <= act) && (act <= up),\
+ error,\
+ "expected within %d-%d, actual %d", low, up, act)
#ifdef __cplusplus