Made lib/base conversion functions const where possible
This commit is contained in:
@@ -18,17 +18,18 @@
|
||||
|
||||
void testing_lib_bytes_to_hword(void)
|
||||
{
|
||||
byte_t tests[][4] = {{0, 0, 0, 0},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{1},
|
||||
{0, 0, 0, 0b10000000},
|
||||
{0x89, 0xab, 0xcd, 0xef}};
|
||||
const byte_t tests[][4] = {{0, 0, 0, 0},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{1},
|
||||
{0, 0, 0, 0b10000000},
|
||||
{0x89, 0xab, 0xcd, 0xef}};
|
||||
|
||||
hword_t expected[ARR_SIZE(tests)] = {0, HWORD_MAX, 1, 1 << 31, 0xefcdab89};
|
||||
const hword_t expected[ARR_SIZE(tests)] = {0, HWORD_MAX, 1, 1 << 31,
|
||||
0xefcdab89};
|
||||
|
||||
for (size_t i = 0; i < ARR_SIZE(tests); ++i)
|
||||
{
|
||||
hword_t got = convert_bytes_to_hword(tests[i]);
|
||||
const hword_t got = convert_bytes_to_hword(tests[i]);
|
||||
if (expected[i] != got)
|
||||
{
|
||||
FAIL(__func__, "[%lu] -> Expected 0x%x got 0x%x\n", i, expected[i], got);
|
||||
@@ -40,18 +41,18 @@ void testing_lib_bytes_to_hword(void)
|
||||
|
||||
void testing_lib_bytes_to_word(void)
|
||||
{
|
||||
byte_t tests[][8] = {{0, 0, 0, 0},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x01, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0b10000000},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}};
|
||||
const byte_t tests[][8] = {{0, 0, 0, 0},
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
|
||||
{0x01, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0b10000000},
|
||||
{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}};
|
||||
|
||||
word_t expected[ARR_SIZE(tests)] = {0, WORD_MAX, 1, 1LU << 63,
|
||||
const word_t expected[ARR_SIZE(tests)] = {0, WORD_MAX, 1, 1LU << 63,
|
||||
|
||||
0xefcdab8967452301};
|
||||
0xefcdab8967452301};
|
||||
for (size_t i = 0; i < ARR_SIZE(tests); ++i)
|
||||
{
|
||||
word_t got = convert_bytes_to_word(tests[i]);
|
||||
const word_t got = convert_bytes_to_word(tests[i]);
|
||||
if (expected[i] != got)
|
||||
{
|
||||
FAIL(__func__, "[%lu] -> Expected 0x%lx got 0x%lx\n", i, expected[i],
|
||||
|
||||
Reference in New Issue
Block a user