-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_test.go
39 lines (30 loc) · 850 Bytes
/
hello_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import "testing"
func TestHello(t *testing.T) {
assertCorrectMessage := func(t testing.TB, got, want string) {
t.Helper()
if got != want {
t.Errorf("got %q want %q", got, want)
}
}
t.Run("saying hello to people", func(t *testing.T) {
got := hello("Chris", "")
want := englishHelloPrefix + "Chris"
assertCorrectMessage(t, got, want)
})
t.Run("say 'Hello, world' when an empty string is supplied", func(t *testing.T) {
got := hello("", "")
want := englishHelloPrefix + "world"
assertCorrectMessage(t, got, want)
})
t.Run("in Spanish", func(t *testing.T) {
got := hello("Elodie", "Spanish")
want := "Hola, Elodie"
assertCorrectMessage(t, got, want)
})
t.Run("in French", func(t *testing.T) {
got := hello("Alex", "French")
want := "Bon jour, Alex"
assertCorrectMessage(t, got, want)
})
}