package udp

import "testing"

func TestWSJTSender(t *testing.T) {
	cases := []struct {
		msg      string
		wantCall string
		wantCQ   bool
	}{
		{"CQ K1ABC FN42", "K1ABC", true},
		{"CQ DX W2XYZ EM12", "W2XYZ", true},   // modifier "DX" skipped
		{"CQ NA VE3ABC FN03", "VE3ABC", true}, // region modifier skipped
		{"CQ 020 JA1XYZ PM95", "JA1XYZ", true},// zone modifier skipped
		{"W2XYZ K1ABC -10", "K1ABC", false},   // exchange → sender is 2nd call
		{"W2XYZ K1ABC R-10", "K1ABC", false},
		{"W2XYZ K1ABC RR73", "K1ABC", false},
		{"F4BPO K1ABC/P 73", "K1ABC/P", false},// portable call kept
		{"CQ F/DL1ABC JO31", "F/DL1ABC", true},// compound prefix
		// Non-callsign / free text → no sender.
		{"TNX 73 GL", "", false},
		{"K1ABC RR73", "", false}, // only one call + a token → 2nd token not a call
		{"", "", false},
		{"CQ CQ CQ", "", true}, // CQ but no resolvable call
	}
	for _, c := range cases {
		call, cq := wsjtSender(c.msg)
		if call != c.wantCall || cq != c.wantCQ {
			t.Errorf("wsjtSender(%q) = (%q,%v), want (%q,%v)", c.msg, call, cq, c.wantCall, c.wantCQ)
		}
	}
}
