// Chapter 34 example: a table-driven test with t.Run. package grade import "testing" func TestLetter(t *testing.T) { tests := []struct { name string score int want string }{ {"top score", 100, "A"}, {"lowest A", 90, "A"}, {"just below A", 89, "B"}, {"lowest C", 70, "C"}, {"lowest D", 60, "D"}, {"just below D", 59, "F"}, {"zero", 0, "F"}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { got := Letter(tc.score) if got != tc.want { t.Errorf("Letter(%d) = %q, want %q", tc.score, got, tc.want) } }) } }