master
 1package main
 2
 3import "testing"
 4
 5func TestHello(t *testing.T) {
 6	assertCorrectMessage := func(t *testing.T, got, want string) {
 7		t.Helper()
 8		if got != want {
 9			t.Errorf("got %q want %q", got, want)
10		}
11	}
12
13	t.Run("saying hello to people", func(t *testing.T) {
14		got := Hello("mo", "")
15		want := "Hello, mo"
16
17		assertCorrectMessage(t, got, want)
18	})
19
20	t.Run("say 'Hello, World' when an empty string is supplied", func(t *testing.T) {
21		got := Hello("", "")
22		want := "Hello, World"
23
24		assertCorrectMessage(t, got, want)
25	})
26
27	t.Run("in Spanish", func(t *testing.T) {
28		got := Hello("Elodie", "Spanish")
29		want := "Hola, Elodie"
30		assertCorrectMessage(t, got, want)
31	})
32
33	t.Run("in French", func(t *testing.T) {
34		got := Hello("Elodie", "French")
35		want := "Bonjour, Elodie"
36		assertCorrectMessage(t, got, want)
37	})
38}