package adif import "testing" func TestNormaliseQSLVia(t *testing.T) { for in, want := range map[string]string{ "B": "B", "b": "B", "Bureau": "B", "BUREAU": "B", " buro ": "B", "D": "D", "Direct": "D", "direct": "D", "E": "E", "Electronic": "E", "électronique": "E", "OQRS": "E", "M": "M", "Manager": "M", // A manager's callsign is not a routing method, and neither is noise. "M0OXO": "", "EA5GL": "", "": "", "Bureau via M0OXO": "", "X": "", } { if got := NormaliseQSLVia(in); got != want { t.Errorf("NormaliseQSLVia(%q) = %q, want %q", in, got, want) } } } // The repair moves values out of the manager column. A false positive would // erase a real manager, so the guard is worth its own test: every callsign-like // value must be refused. func TestIsQSLViaRoutingRefusesManagers(t *testing.T) { for _, call := range []string{ "M0OXO", "EA5GL", "F5CWU", "DJ9ZB", "W3HNK", "IK2DUW", "N7RO", "BUREAU M0OXO", "via bureau DL1XYZ", "QSL DIRECT ONLY", } { if IsQSLViaRouting(call) { t.Errorf("%q was taken for a routing method — the repair would erase it", call) } } for _, v := range []string{"B", "D", "E", "M", "Bureau", "Direct", "Electronic"} { if !IsQSLViaRouting(v) { t.Errorf("%q should be recognised as a routing method", v) } } }