mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-21 13:24:30 -04:00
SymField rewrite (#1444)
* First WIP symfield * Cleanup widget code * Rebase and format * Fix 'to_integer' bug, fix siggen UI. * to_string_hex fix, unit tests for string code * Pass instance in callback * Fix on_change callbacks * Fix keyfob (not active) * to_byte_array, coaster tx cleanup * Add to_byte_array tests * Changes in ui_numbers * Fix ui_encoders * Format * Fix modemsetup view's symfields * Remove header * Format
This commit is contained in:
parent
70e0f2913f
commit
af424aa5f8
30 changed files with 607 additions and 371 deletions
|
@ -83,6 +83,54 @@ TEST_CASE("to_string_rounded_freq returns correct value.") {
|
|||
CHECK_EQ(to_string_rounded_freq(1'234'567'891, 9), "1234.567891");
|
||||
}
|
||||
|
||||
TEST_CASE("to_string_hex returns correct value.") {
|
||||
CHECK_EQ(to_string_hex(0x0, 1), "0");
|
||||
CHECK_EQ(to_string_hex(0x0, 4), "0000");
|
||||
CHECK_EQ(to_string_hex(0x1, 1), "1");
|
||||
CHECK_EQ(to_string_hex(0xA, 1), "A");
|
||||
CHECK_EQ(to_string_hex(0xA0, 2), "A0");
|
||||
CHECK_EQ(to_string_hex(0xA1, 2), "A1");
|
||||
CHECK_EQ(to_string_hex(0xA1FE, 2), "FE"); // NB: Truncates front.
|
||||
CHECK_EQ(to_string_hex(0x12345678, 8), "12345678");
|
||||
CHECK_EQ(to_string_hex(0x9ABCDEF0, 8), "9ABCDEF0");
|
||||
}
|
||||
|
||||
TEST_CASE("to_string_hex returns correct value based on type.") {
|
||||
CHECK_EQ(to_string_hex<uint8_t>(0xA), "0A");
|
||||
CHECK_EQ(to_string_hex<uint8_t>(0xFE), "FE");
|
||||
CHECK_EQ(to_string_hex<uint16_t>(0x00FE), "00FE");
|
||||
CHECK_EQ(to_string_hex<uint16_t>(0xCAFE), "CAFE");
|
||||
CHECK_EQ(to_string_hex<uint32_t>(0xCAFE), "0000CAFE");
|
||||
CHECK_EQ(to_string_hex<uint32_t>(0xCAFEBEEF), "CAFEBEEF");
|
||||
CHECK_EQ(to_string_hex<uint64_t>(0xCAFEBEEF), "00000000CAFEBEEF");
|
||||
CHECK_EQ(to_string_hex<uint64_t>(0xC0FFEE00CAFEBABE), "C0FFEE00CAFEBABE");
|
||||
}
|
||||
|
||||
TEST_CASE("char_to_uint returns correct value.") {
|
||||
CHECK_EQ(char_to_uint('0', 10), 0);
|
||||
CHECK_EQ(char_to_uint('5', 10), 5);
|
||||
CHECK_EQ(char_to_uint('8', 8), 0); // Bad value given radix.
|
||||
CHECK_EQ(char_to_uint('8', 10), 8);
|
||||
CHECK_EQ(char_to_uint('8', 16), 8);
|
||||
CHECK_EQ(char_to_uint('A', 10), 0); // Bad value given radix.
|
||||
CHECK_EQ(char_to_uint('A', 16), 0xA);
|
||||
CHECK_EQ(char_to_uint('a', 16), 0xA); // Lowercase.
|
||||
CHECK_EQ(char_to_uint('f', 16), 0xF); // Lowercase.
|
||||
CHECK_EQ(char_to_uint('G', 16), 0); // Bad value given radix.
|
||||
}
|
||||
|
||||
TEST_CASE("uint_to_char returns correct value.") {
|
||||
CHECK_EQ(uint_to_char(0, 10), '0');
|
||||
CHECK_EQ(uint_to_char(5, 10), '5');
|
||||
CHECK_EQ(uint_to_char(8, 8), '\0'); // Bad value given radix.
|
||||
CHECK_EQ(uint_to_char(8, 10), '8');
|
||||
CHECK_EQ(uint_to_char(8, 16), '8');
|
||||
CHECK_EQ(uint_to_char(10, 10), '\0'); // Bad value given radix.
|
||||
CHECK_EQ(uint_to_char(10, 16), 'A');
|
||||
CHECK_EQ(uint_to_char(15, 16), 'F');
|
||||
CHECK_EQ(uint_to_char(16, 16), '\0'); // Bad value given radix.
|
||||
}
|
||||
|
||||
TEST_CASE("trim removes whitespace.") {
|
||||
CHECK(trim(" foo\n") == "foo");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue