diff options
| author | hathach <[email protected]> | 2013-01-13 20:39:01 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-01-13 20:39:01 +0700 |
| commit | f9914751833deb1b135568b7c09271261f356a06 (patch) | |
| tree | e64aae9020e1682cc2dace9a99472451c9e5b535 /tinyusb | |
| parent | b7b9531b9bb6e9a2fb6f85ae586c91bd29ef92e5 (diff) | |
add assert_hex & assert_hex_within
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/common/assertion.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h index 26dad566a..8fc19289a 100644 --- a/tinyusb/common/assertion.h +++ b/tinyusb/common/assertion.h @@ -105,8 +105,6 @@ extern "C" //--------------------------------------------------------------------+ // Integer Assert //--------------------------------------------------------------------+ -#define TEST_INT_EQUAL - #define ASSERT_INT(...) ASSERT_INT_EQUAL(__VA_ARGS__) #define ASSERT_INT_EQUAL(expected, actual, error) \ ASSERT_DEFINE(\ @@ -122,6 +120,23 @@ extern "C" error,\ "expected within %d-%d, actual %d", low, up, act) +//--------------------------------------------------------------------+ +// Hex Assert +//--------------------------------------------------------------------+ +#define ASSERT_HEX(...) ASSERT_HEX_EQUAL(__VA_ARGS__) +#define ASSERT_HEX_EQUAL(expected, actual, error) \ + ASSERT_DEFINE(\ + uint32_t exp = (expected); uint32_t act = (actual),\ + exp==act,\ + error,\ + "expected 0x%x, actual 0x%x", exp, act) + +#define ASSERT_HEX_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 0x%x-0x%x, actual 0x%x", low, up, act) #ifdef __cplusplus } |
