package main import "testing" // The case that started this: WSJT-X / MSHV can only send a 4-character grid, so // a digital QSO arrived with JN05 while QRZ knew JN05JG — and the fill-if-empty // enrichment rule kept the coarse one. Roughly 100 km of accuracy, silently lost // on every digital QSO. func TestRefineGrid(t *testing.T) { cases := []struct{ have, found, want, why string }{ {"JN05", "JN05JG", "JN05JG", "the lookup EXTENDS the received square — take the precise one"}, {"jn05", "JN05JG", "JN05JG", "grids arrive in both cases"}, {"", "JN05JG", "JN05JG", "nothing received — take whatever was found"}, {"JN05JG", "", "JN05JG", "nothing found — keep what was received"}, {"JN05JG", "JN05", "JN05JG", "never trade a precise grid for a coarse one"}, {"JN05JG", "JN05JG", "JN05JG", "same grid"}, // A DISAGREEMENT is not a refinement: the station may be portable, and // what came over the air is then the better record. {"JN05", "JN18AA", "JN05", "different square — keep what was actually received"}, {"JN18AA", "JN05", "JN18AA", "different square, coarse lookup — keep the received one"}, {"", "", "", "nothing either way"}, } for _, c := range cases { if got := refineGrid(c.have, c.found); got != c.want { t.Errorf("refineGrid(%q, %q) = %q, want %q — %s", c.have, c.found, got, c.want, c.why) } } }