Reported with real callsigns: every Asiatic Russia contact logged CQ 17 / ITU 30, whatever the operator's real zone. RU0LL and RA0FF are 19/34, UA0SDX is 18/32, and QRZ.com had all three right. Measured before touching anything: cty.dat answers 17/30 for RU0, RA0, UA0 and UA9 alike — one representative pair for a country eight CQ zones wide — while ClubLog's prefix table gives 19, 19, 18 and 17. The reporter's instinct that no UA0 sits in CQ 17 was exactly right. fillFromDXCC overrode the callbook's zones on purpose, and the reason holds only for the country: QRZ returns the political nation where cty.dat returns the DXCC entity. A zone answers a different question — not what the callsign IS but where the station SITS — and there the per-station page beats a country default. Zones now FILL rather than override; the entity is untouched. The cache made it worse by remembering our conclusion as though the page had said it, so the wrong zones would have outlived this fix. A lookup is now cached as the callbook returned it and the country file is applied on read, which also lets a cty.dat update reach old rows.
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package lookup
|
|
|
|
import "testing"
|
|
|
|
// asiaticRussia stands in for cty.dat: one representative zone pair for a
|
|
// country eight CQ zones wide.
|
|
func asiaticRussia(cqz, ituz int) fakeDXCC {
|
|
return fakeDXCC{"RU0LL": {num: 15, country: "Asiatic Russia", cont: "AS", cqz: cqz, ituz: ituz}}
|
|
}
|
|
|
|
// A zone is where the station SITS; an entity is what the callsign IS. Asiatic
|
|
// Russia spans CQ 16-23 and ITU 20-34, and cty.dat carries one representative
|
|
// pair for the whole country — so stamping it over a callbook's per-station
|
|
// answer records a WAZ credit for a zone the operator never worked.
|
|
//
|
|
// Reported with real callsigns: RU0LL is CQ 19 / ITU 34 and was logged 17/30.
|
|
func TestCallbookZonesSurviveTheEntityDefault(t *testing.T) {
|
|
// What QRZ said about this very station.
|
|
r := Result{Callsign: "RU0LL", CQZ: 19, ITUZ: 34}
|
|
fillFromDXCC(&r, asiaticRussia(17, 30))
|
|
if r.CQZ != 19 || r.ITUZ != 34 {
|
|
t.Errorf("callbook zones were overwritten: CQ%d ITU%d, want CQ19 ITU34", r.CQZ, r.ITUZ)
|
|
}
|
|
if r.Country != "Asiatic Russia" {
|
|
t.Errorf("the ENTITY must still come from cty.dat, got %q", r.Country)
|
|
}
|
|
}
|
|
|
|
func TestEntityZonesFillSilence(t *testing.T) {
|
|
// A callbook that says nothing about zones still gets an answer.
|
|
r := Result{Callsign: "RU0LL"}
|
|
fillFromDXCC(&r, asiaticRussia(17, 30))
|
|
if r.CQZ != 17 || r.ITUZ != 30 {
|
|
t.Errorf("empty zones were not filled: CQ%d ITU%d", r.CQZ, r.ITUZ)
|
|
}
|
|
}
|