Родитель
f4539baa21
Сommit
f743eab840
@ -0,0 +1,20 @@
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
char nibble_to_hex(uint8_t i) {
|
||||
assert(0x0 <= i && i <= 0xf);
|
||||
if (i < 10) return '0' + i;
|
||||
return 'a' + (i - 10);
|
||||
}
|
||||
|
||||
void test_nibble_to_hex() {
|
||||
assert(nibble_to_hex(0x0) == '0');
|
||||
assert(nibble_to_hex(0xf) == 'f');
|
||||
cout << "nibble_to_hex() tests passed!\n";
|
||||
}
|
||||
|
||||
int main() {
|
||||
test_nibble_to_hex();
|
||||
return 0;
|
||||
}
|
Загрузка…
Ссылка в новой задаче