/** * \file * * * \brief REVERSE macro test. * * \author Francesco Sacchi */ #include #include #include /* Silent compiler warning */ int reverse_testSetup(void); int reverse_testRun(void); int reverse_testTearDown(void); int reverse_testSetup(void) { kdbg_init(); return 0; } int reverse_testTearDown(void) { return 0; } /** * Naive reverse implementation. */ static uint8_t reverse(uint8_t b) { uint8_t r = 0; for (int i = 0; i < 8; i++) { r <<= 1; r |= (b & BV(i)) ? 1 : 0; } return r; } int reverse_testRun(void) { for (int i = 0; i < 256; i++) { kprintf("i [%02X], REVERSE(i) [%02X], reverse(i) [%02X]\n", i, REVERSE_UINT8(i), reverse(i)); ASSERT(reverse(i) == REVERSE_UINT8(i)); } return 0; } TEST_MAIN(reverse);