package hello import "testing" func TestGreet(t *testing.T) { cases := []struct { why string name string want string }{ {"a name is greeted as it is written", "Bob", "Hello, Bob!"}, {"surrounding whitespace is not part of a name", " Bob\t", "Hello, Bob!"}, {"an empty name still produces a whole greeting", "", "Hello, world!"}, {"a name of nothing but whitespace is an empty name", " ", "Hello, world!"}, {"the inside of a name is left alone", "Ada Lovelace", "Hello, Ada Lovelace!"}, {"a name is not assumed to be ASCII", "Émilie", "Hello, Émilie!"}, } for _, c := range cases { t.Run(c.why, func(t *testing.T) { if got := Greet(c.name); got != c.want { t.Errorf("Greet(%q) = %q, want %q", c.name, got, c.want) } }) } }