-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_test.go
48 lines (38 loc) · 939 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
40
41
42
43
44
45
46
47
48
package main
import "testing"
func TestHello(t *testing.T) {
assertCorrectMessage := func(t *testing.T, 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", "English")
want := "Hello, Chris"
if got != want {
assertCorrectMessage(t, got, want)
}
})
t.Run("saying 'Hello, World' when an empty string is supplied", func(t *testing.T) {
got := Hello("", "English")
want := "Hello, World"
if got != want {
assertCorrectMessage(t, got, want)
}
})
t.Run("in Spanish", func(t *testing.T) {
got := Hello("Elodie", "Spanish")
want := "Hola, Elodie"
if got != want {
assertCorrectMessage(t, got, want)
}
})
t.Run("in French", func(t *testing.T) {
got := Hello("Elodie", "French")
want := "Bonjour, Elodie"
if got != want {
assertCorrectMessage(t, got, want)
}
})
}