package cat import "testing" // The FTDX10 family writes a frequency in nine digits; everything before it — // FTDX3000, FTDX5000, FTDX1200, FT-2000, FT-950, FT-450 — writes eight and // answers a nine-digit SET with "?;". Reported from an FTDX3000: every FA // command rejected, a radio that would not follow. // // The width is taken from the rig's own reply, so a model this backend has // never heard of is right on the first read. func TestYaesuFrequencyWidthIsLearnedFromTheRig(t *testing.T) { y := &Yaesu{} if got := y.freqWidth(); got != 9 { t.Errorf("before any reply the width is %d, want the modern 9", got) } y.learnFreqWidth("FA14074000;", "FA") // an FTDX3000 if got := y.freqWidth(); got != 8 { t.Errorf("width %d after an eight-digit reply, want 8", got) } y.learnFreqWidth("FA014074000;", "FA") // and an FTDX10 on the next session if got := y.freqWidth(); got != 9 { t.Errorf("width %d after a nine-digit reply, want 9", got) } // Nothing that is not a frequency teaches anything: a rejection, a stray // frame or a reply from another command would otherwise set the format for // every command that follows. for _, junk := range []string{"?;", "FA;", "FB014074000;", "FA1407400X;", "FA1234567;", "FA123456789012;"} { before := y.freqWidth() y.learnFreqWidth(junk, "FA") if after := y.freqWidth(); after != before { t.Errorf("%q changed the width from %d to %d", junk, before, after) } } }