up
This commit is contained in:
@@ -54,6 +54,96 @@ func TestLookup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A "/N" call-area suffix can change the DXCC entity: HD5MW/8 re-homes to the
|
||||
// HD8 area (Galápagos), not the base call's Ecuador.
|
||||
func TestCallAreaSuffix(t *testing.T) {
|
||||
const cty = `Ecuador: 10: 12: SA: -1.40: 78.40: 5.0: HC:
|
||||
HC,HD;
|
||||
Galapagos Islands: 10: 12: SA: 0.00: 91.00: 6.0: HC8:
|
||||
HC8,HD8;
|
||||
`
|
||||
db, err := Load(strings.NewReader(cty))
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
cases := map[string]string{
|
||||
"HD5MW": "Ecuador",
|
||||
"HD5MW/8": "Galapagos Islands",
|
||||
"HC2AO": "Ecuador",
|
||||
"HD8M": "Galapagos Islands",
|
||||
"HC1WW/8": "Galapagos Islands",
|
||||
}
|
||||
for call, want := range cases {
|
||||
m, ok := db.Lookup(call)
|
||||
if !ok {
|
||||
t.Errorf("%s: no match", call)
|
||||
continue
|
||||
}
|
||||
if m.Entity.Name != want {
|
||||
t.Errorf("%s: got %q, want %q", call, m.Entity.Name, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// US/VK call-district zone refinement (W6 = CQ3/ITU6, not the entity default).
|
||||
func TestZoneByCallDistrict(t *testing.T) {
|
||||
cases := []struct {
|
||||
adif int
|
||||
call string
|
||||
cqz, ituz int
|
||||
ok bool
|
||||
}{
|
||||
{291, "W6XYZ", 3, 6, true},
|
||||
{291, "K7AB", 3, 6, true},
|
||||
{291, "W4ABC", 5, 8, true},
|
||||
{291, "N0CALL", 4, 7, true},
|
||||
{291, "AA5XX", 4, 7, true},
|
||||
{150, "VK6AA", 29, 58, true}, // West Australia
|
||||
{150, "VK3XY", 30, 59, true}, // Victoria
|
||||
{230, "DL1ABC", 0, 0, false}, // Germany: no district rule
|
||||
{291, "WABC", 0, 0, false}, // no digit
|
||||
}
|
||||
for _, c := range cases {
|
||||
cqz, ituz, ok := ZoneByCallDistrict(c.adif, c.call)
|
||||
if ok != c.ok || (ok && (cqz != c.cqz || ituz != c.ituz)) {
|
||||
t.Errorf("ZoneByCallDistrict(%d,%q) = %d/%d ok=%v, want %d/%d ok=%v",
|
||||
c.adif, c.call, cqz, ituz, ok, c.cqz, c.ituz, c.ok)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// KG4 is Guantanamo Bay only with a 2-character suffix (KG4XX); 1- or 3-char
|
||||
// suffixes (KG4W, KG4ABC) are continental USA. cty.dat carries a bare "KG4"
|
||||
// prefix, so the resolver must apply the suffix-length rule.
|
||||
func TestKG4SuffixRule(t *testing.T) {
|
||||
const cty = `United States: 05: 08: NA: 37.53: 91.67: 5.0: K:
|
||||
K,N,W;
|
||||
Guantanamo Bay: 08: 11: NA: 19.92: 75.18: -5.0: KG4:
|
||||
KG4;
|
||||
`
|
||||
db, err := Load(strings.NewReader(cty))
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
cases := map[string]string{
|
||||
"KG4W": "United States", // 1-char suffix
|
||||
"KG4AA": "Guantanamo Bay", // 2-char suffix
|
||||
"KG4ABC": "United States", // 3-char suffix
|
||||
"KG4": "United States", // no suffix
|
||||
"KG4W/P": "United States", // modifier stripped, still 1-char
|
||||
}
|
||||
for call, want := range cases {
|
||||
m, ok := db.Lookup(call)
|
||||
if !ok {
|
||||
t.Errorf("%s: no match", call)
|
||||
continue
|
||||
}
|
||||
if m.Entity.Name != want {
|
||||
t.Errorf("%s: got %q, want %q", call, m.Entity.Name, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cty.dat marks non-DXCC entities (Sicily *IT9, African Italy *IG9) with a
|
||||
// leading '*'; the parser must fold those into their parent DXCC entity
|
||||
// "Italy" while leaving real DXCC entities — Sardinia (IS0), no '*' — alone.
|
||||
@@ -108,9 +198,14 @@ func TestNormalize(t *testing.T) {
|
||||
"f4bpo": "F4BPO",
|
||||
" F4BPO ": "F4BPO",
|
||||
"F4BPO/P": "F4BPO",
|
||||
"F4BPO/MM": "F4BPO",
|
||||
"F4BPO/5": "F4BPO",
|
||||
"F4BPO/MM": "", // maritime mobile → no DXCC entity
|
||||
"F4BPO/AM": "", // aeronautical mobile → no DXCC entity
|
||||
"F4BPO/M": "F4BPO", // plain mobile keeps the home entity
|
||||
"F4BPO/5": "F5BPO", // "/5" re-homes to call area 5
|
||||
"HD5MW/8": "HD8MW", // "/8" → Galápagos call area (HD8)
|
||||
"DL/F4BPO": "DL",
|
||||
"MM/KA9P": "MM", // leading MM = Scotland operating prefix
|
||||
"MM/LY3X/P": "MM",
|
||||
"F4BPO/W6": "W6",
|
||||
"VK9/F4BPO": "VK9",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user