package dxcc

import "testing"

// /MM and /AM belong to NO DXCC entity: the station is at sea or in the air.
//
// This is not a technicality. RI1FJL/MM resolved to Franz Josef Land while the
// expedition was still sailing there, which told the operator they had worked
// an entity they had not.
func TestMobileNoEntity(t *testing.T) {
	for _, tc := range []struct {
		call string
		want bool
	}{
		{"RI1FJL/MM", true},
		{"YB1SCY/AM", true},
		{"ri1fjl/mm", true},
		{" RI1FJL/MM ", true},
		// A LEADING MM is Scotland and AM is Spain. Treating those as
		// entity-less would be a far larger error than the one this fixes.
		{"MM0ABC", false},
		{"AM5X", false},
		{"MM/F4BPO", false},
		{"AM/DL1ABC", false},
		// Other suffixes keep their entity — a portable station is still ashore.
		{"F4BPO/P", false},
		{"F4BPO/M", false},
		{"4U1UN/B", false},
		{"F4BPO", false},
		// Only the LAST element counts: RI1FJL/MM/P is still maritime, and a
		// call whose /MM is not final is not.
		{"RI1FJL/MM/P", false},
		{"", false},
	} {
		if got := IsMobileNoEntity(tc.call); got != tc.want {
			t.Errorf("IsMobileNoEntity(%q) = %v, want %v", tc.call, got, tc.want)
		}
	}
}
