package dxcc

import "testing"

// The contact that reported this: R1MVI, worked in 2004 on Malyj Vysotskij
// Island, entity 151, deleted in February 2012. cty.dat resolves that callsign
// to European Russia (54) today, so anything that re-stamps an old QSO from a
// callsign has to know to stop here.
func TestMalyjVysotskijIsKnownDeleted(t *testing.T) {
	if !IsDeleted(151) {
		t.Fatal("151 (Malyj Vysotskij I.) must be known as deleted — the whole guard hangs on it")
	}
	if got := DeletedName(151); got == "" {
		t.Error("a deleted entity should be able to say what it was called")
	}
}

// The guard must not fire on entities that are alive, or every log would freeze
// at whatever DXCC number it was imported with — including the wrong ones.
func TestLiveEntitiesAreNotTreatedAsDeleted(t *testing.T) {
	live := map[int]string{
		54:  "European Russia — what R1MVI resolves to today",
		227: "France",
		291: "United States",
		339: "Japan",
		1:   "Canada",
	}
	for n, what := range live {
		if IsDeleted(n) {
			t.Errorf("%d (%s) must not be listed as deleted", n, what)
		}
	}
	if got := DeletedName(54); got != "" {
		t.Errorf("DeletedName(54) = %q, want empty", got)
	}
}

// A few more from the ADIF enumeration, so a careless edit to the table is
// caught rather than discovered by an operator whose credits moved.
func TestSomeOtherDeletedEntities(t *testing.T) {
	for _, n := range []int{218 /* Czechoslovakia */, 229 /* German DR */, 255 /* St. Maarten, Saba, St. Eustatius */, 28 /* Canal Zone */} {
		if !IsDeleted(n) {
			t.Errorf("%d should be a deleted entity", n)
		}
	}
}
