diff --git a/lab04/lab04.cpp b/lab04/lab04.cpp index 315510a..cc4e256 100644 --- a/lab04/lab04.cpp +++ b/lab04/lab04.cpp @@ -14,7 +14,22 @@ void test_nibble_to_hex() { cout << "nibble_to_hex() tests passed!\n"; } +uint8_t low_nibble(uint8_t byte) { + return byte & 0x0f; +} + +uint8_t high_nibble(uint8_t byte) { + return byte >> 4; +} + +void test_nibbles() { + assert(low_nibble(0xab) == 0xb); + assert(high_nibble(0xab) == 0xa); + cout << "Nibble extraction tests passed!\n"; +} + int main() { test_nibble_to_hex(); + test_nibbles(); return 0; }