|
|
@ -14,7 +14,22 @@ void test_nibble_to_hex() {
|
|
|
|
cout << "nibble_to_hex() tests passed!\n";
|
|
|
|
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() {
|
|
|
|
int main() {
|
|
|
|
test_nibble_to_hex();
|
|
|
|
test_nibble_to_hex();
|
|
|
|
|
|
|
|
test_nibbles();
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|