Реализована функция nibble_to_hex с тестами
Этот коммит содержится в:
20
lab04/lab04.cpp
Обычный файл
20
lab04/lab04.cpp
Обычный файл
@@ -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;
|
||||
}
|
||||
Ссылка в новой задаче
Block a user