#include #include #include #include bool test_decode(const char *ref, const ham64_t *ham64) { char decoded[13]; decoded[12] = 0; char ham64_format_buf[HAM64_FMT_MAX_LEN]; size_t decoded_len = ham64_decode_callsign(ham64, decoded); ham64_format(ham64, ham64_format_buf); const char *typestr = ham64_addr_type_to_string(ham64_get_addr_type(ham64)); printf("»%s« → [%u] %s (%s) → [%zd] »%s«\n", ref, ham64->length, ham64_format_buf, typestr, decoded_len, decoded); return strcmp(ref, decoded) == 0; } bool test_call(const char *call) { ham64_t ham64; ham64_encode(call, &ham64); return test_decode(call, &ham64); } int main(void) { char *call1 = "VI2BMARC50-X"; char *call2 = "DL5TKL/T"; char *call3 = "D9K"; ham64_t empty = {{0x0000, 0x0, 0x0, 0x0}, 1}; ham64_t short_1 = {{0x0001, 0x0, 0x0, 0x0}, 1}; ham64_t short_last = {{0x063F, 0x0, 0x0, 0x0}, 1}; ham64_t broadcast = {{0xFFFF, 0x0, 0x0, 0x0}, 1}; test_call(call1); test_call(call2); test_call(call3); test_decode("", &empty); test_decode("", &short_1); test_decode("", &short_last); test_decode("", &broadcast); }