package udp import "testing" // A remote-call arrives in whatever unit the sender happens to use, and // the same sender uses more than one. Every form has to land on the same dial // frequency, because the alternative is a rig sent to the wrong band. func TestRemoteTuneUnits(t *testing.T) { const m20 = 14_074_000 for _, c := range []struct { in string want int64 why string }{ {"14.074", m20, "MHz, the documented DXHunter form"}, {"10.136", 10_136_000, "MHz, 30 m"}, {"14074", m20, "kHz"}, {"14074.0", m20, "kHz with a decimal point"}, {"1407400", m20, "tens of Hz — what N1MM RadioInfo publishes, echoed back"}, {"2107400", 21_074_000, "the value from the field log that failed every time"}, {"14074000", m20, "Hz"}, {"7000000", 7_000_000, "Hz on 40 m, not tens of Hz on 4 m"}, {"0", 0, "no frequency"}, {"999999999999", 0, "nothing plausible — tune nothing rather than guess"}, {"abc", 0, "not a number"}, } { if got := remoteTuneHz(c.in); got != c.want { t.Errorf("remoteTuneHz(%q) = %d, want %d (%s)", c.in, got, c.want, c.why) } } }