Something went wrong. Try again.
A lightweight geocoding server
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051package normalize
import "testing"
func TestText(t *testing.T) { cases := []struct { name string in string want string }{ {"lowercases", "State St", "state st"}, {"strips punctuation", "O'Neil St.", "o neil st"}, {"collapses whitespace", " 210 State Street ", "210 state street"}, {"strips accents", "Rivière-du-Loup", "riviere du loup"}, {"empty", "", ""}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { if got := Text(c.in); got != c.want { t.Errorf("Text(%q) = %q, want %q", c.in, got, c.want) } }) }}
func TestExpand(t *testing.T) { cases := []struct { name string in string want string }{ {"street type", "state st", "state street"}, {"multiple abbreviations", "n main st", "north main street"}, {"already long", "state street", "state street"}, {"empty", "", ""}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { if got := Expand(c.in); got != c.want { t.Errorf("Expand(%q) = %q, want %q", c.in, got, c.want) } }) }}
func TestNameAgreesAcrossSpellings(t *testing.T) { if Name("State St") != Name("state STREET") { t.Error("abbreviated and long spellings must normalize to the same name") }}