package cat

import "testing"

func TestTCISpotsUnsupported(t *testing.T) {
	// SPOT arrived in TCI 1.5. The SunSDR2 PRO report that prompted this was an
	// ExpertSDR announcing 1.3 — spots accepted and silently dropped.
	for _, c := range []struct {
		version string
		old     bool
	}{
		{"1.3", true},
		{"1.4", true},
		{"1.5", false},
		{"1.9", false},
		{"2.0", false},
		{"", false},      // unparseable → assume it works
		{"weird", false}, // refusing to draw on a doubt is the worse mistake
	} {
		if got := tciSpotsUnsupported(c.version); got != c.old {
			t.Errorf("tciSpotsUnsupported(%q) = %v, want %v", c.version, got, c.old)
		}
	}
}

func TestSanitiseTCICW(t *testing.T) {
	// The separators must never survive: a comma would become another argument
	// and a semicolon would end the command with the message half sent.
	for _, c := range []struct{ in, want string }{
		{"cq cq de f4bpo", "CQ CQ DE F4BPO"},
		{" tu 599 ", "TU 599"},
		{"73, gl", "73  GL"},
		{"test;cw_macros_stop", "TEST CW_MACROS_STOP"},
		{"line\r\nbreak", "LINE  BREAK"},
		{"   ", ""},
	} {
		if got := sanitiseTCICW(c.in); got != c.want {
			t.Errorf("sanitiseTCICW(%q) = %q, want %q", c.in, got, c.want)
		}
	}
}
