package main import "testing" // A band change now has two sources: the rig, and the entry strip on a station // whose rig OpsLog does not control. They share one memory of the last band, so // a station that has both commands its antenna switch once per QSY rather than // twice — the entry selector pushes a QSY, the rig reports the same band back, // and only the first of the two is a change. func TestBandChangeIsNotedOncePerBand(t *testing.T) { lastTriggerBandMu.Lock() lastTriggerBand = "" lastTriggerBandMu.Unlock() if b, changed := noteBandChange("20m"); !changed || b != "20m" { t.Fatalf("first 20m = (%q,%v), want (\"20m\",true)", b, changed) } // The same band from the other source — the rig echoing the QSY back. if _, changed := noteBandChange("20M"); changed { t.Error("the rig echoing the band back counted as a second change — the switch would be commanded twice") } if _, changed := noteBandChange(" 20m "); changed { t.Error("whitespace made the same band look new") } if b, changed := noteBandChange("40m"); !changed || b != "40m" { t.Errorf("40m = (%q,%v), want (\"40m\",true)", b, changed) } // An unknown band must not be recorded, or the next real one would look // unchanged against it. if _, changed := noteBandChange(""); changed { t.Error("an empty band was treated as a change") } if _, changed := noteBandChange("40m"); changed { t.Error("the empty band overwrote the last one") } }