package cat import ( "strings" "testing" ) // The TS-590 wants a FIXED 24-character P2. Sending the bare text is what made // CW over CAT fail on a real TS-590SG: "KY OH5CX;" came back "?;", which OpsLog // reported as "this radio rejected CW over CAT" and sent the operator off to buy // a serial keyer he did not need. func TestKenwoodCWPadsToTheFixedWidth(t *testing.T) { k := &Kenwood{} got := k.padCW("OH5CX") if len(got) != kenwoodCWChunk { t.Errorf("padCW(%q) is %d chars, want exactly %d — the rig rejects anything else", "OH5CX", len(got), kenwoodCWChunk) } if got[:5] != "OH5CX" || strings.TrimRight(got, " ") != "OH5CX" { t.Errorf("padCW = %q — the text must be intact and the rest spaces", got) } // A full piece is already the right width and must not grow. full := strings.Repeat("A", kenwoodCWChunk) if k.padCW(full) != full { t.Error("a full 24-character piece was padded further") } // Elecraft takes variable length, and padding there would key the trailing // spaces as word gaps. e := &Kenwood{elecraft: true} if e.padCW("OH5CX") != "OH5CX" { t.Errorf("Elecraft piece was padded: %q", e.padCW("OH5CX")) } } // ";" terminates a CAT frame. The manual forbids it in P2, and one arriving in a // macro would close the command early and leave the rest to be read as commands. func TestKenwoodCWDropsTheSemicolon(t *testing.T) { if got := filterKenwoodCW("CQ; DE OH5CX"); strings.Contains(got, ";") { t.Errorf("filterKenwoodCW kept a semicolon: %q", got) } }