package lookup import "testing" // The district only ever reaches the log if it has the RIGHT SHAPE. HamQTH's // oblast field is filled by hand, so it arrives in whatever form the operator's // editor encouraged — and anything that is not a district reference must yield // nothing at all rather than a reference no list contains. func TestRDARef(t *testing.T) { for _, c := range []struct{ in, want string }{ {"KE-29", "KE-29"}, {"ke-29", "KE-29"}, {" KE-29 ", "KE-29"}, {"KE-29 Kemerovskaya obl.", "KE-29"}, {"Kemerovskaya obl. (KE-29)", "KE-29"}, {"", ""}, {"Kemerovskaya oblast", ""}, // a name, not a reference {"KE", ""}, // the oblast alone carries no district {"KE-1", ""}, // one digit is not an RDA {"KE-291", ""}, // three digits is not one either {"650000", ""}, // a postal code {"EU-064", ""}, // an IOTA reference in the wrong field } { if got := rdaRef(c.in); got != c.want { t.Errorf("rdaRef(%q) = %q, want %q", c.in, got, c.want) } } // oblast wins over district; an empty first field falls through to the next. if got := rdaRef("", "MO-19"); got != "MO-19" { t.Errorf("fallback to district = %q, want MO-19", got) } if got := rdaRef("KE-29", "MO-19"); got != "KE-29" { t.Errorf("oblast must win, got %q", got) } }