diff options
| author | hathach <[email protected]> | 2013-01-31 11:05:33 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-01-31 11:05:33 +0700 |
| commit | eca87e5ee54f688372d2d34ee51dc3f72947d604 (patch) | |
| tree | 4b9575ca8f4e90a6636c15aef6c8fe3918a26f5e /tinyusb/common | |
| parent | 658b2b970c23c5f88b369869d947e047f96e2f72 (diff) | |
add ASSERT_BIN8 and its test code
add some common api for task in osal.h for mocking
Diffstat (limited to 'tinyusb/common')
| -rw-r--r-- | tinyusb/common/assertion.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h index 211a96073..5d26311fd 100644 --- a/tinyusb/common/assertion.h +++ b/tinyusb/common/assertion.h @@ -146,6 +146,24 @@ extern "C" //--------------------------------------------------------------------+ // TODO Bin Assert //--------------------------------------------------------------------+ +#define BIN8_PRINTF_PATTERN "%d%d%d%d%d%d%d%d" +#define BIN8_PRINTF_CONVERT(byte) \ + ((byte) & 0x80 ? 1 : 0), \ + ((byte) & 0x40 ? 1 : 0), \ + ((byte) & 0x20 ? 1 : 0), \ + ((byte) & 0x10 ? 1 : 0), \ + ((byte) & 0x08 ? 1 : 0), \ + ((byte) & 0x04 ? 1 : 0), \ + ((byte) & 0x02 ? 1 : 0), \ + ((byte) & 0x01 ? 1 : 0) + +#define ASSERT_BIN8(...) ASSERT_BIN8_EQUAL(__VA_ARGS__) +#define ASSERT_BIN8_EQUAL(expected, actual, error)\ + ASSERT_DEFINE(\ + uint8_t exp = (expected); uint8_t act = (actual),\ + exp==act,\ + error,\ + "expected " BIN8_PRINTF_PATTERN ", actual " BIN8_PRINTF_PATTERN, BIN8_PRINTF_CONVERT(exp), BIN8_PRINTF_CONVERT(act) ) //--------------------------------------------------------------------+ // TODO Bit Assert |
