-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_test.go
70 lines (52 loc) · 1.21 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import "testing"
func TestHello(t *testing.T) {
t.Run("say hello with a person's name", func(t *testing.T) {
got := Hello("Chris", "")
want := "Hello, Chris"
if got != want {
printError(t, got, want)
}
})
t.Run("Don't supply a name default to hello world in English", func(t *testing.T) {
got := Hello("", "")
want := "Hello, World"
if got != want {
printError(t, got, want)
}
})
t.Run("Don't supply a name default to hello world in Spanish", func(t *testing.T) {
got := Hello("", "Spanish")
want := "Hola, World"
if got != want {
printError(t, got, want)
}
})
t.Run("in Spanish", func(t *testing.T){
got := Hello("Elodie", "Spanish")
want := "Hola, Elodie"
if got != want {
printError(t, got, want)
}
})
t.Run("in French", func(t *testing.T){
got := Hello("Elodie", "French")
want := "Bonjour, Elodie"
if got != want {
printError(t, got, want)
}
})
t.Run("in Japanese", func(t *testing.T){
got := Hello("Elodie", "Japanese")
want := "Kon'nichiwa, Elodie"
if got != want {
printError(t, got, want)
}
})
}
func printError(t testing.TB, got, want string) {
t.Helper()
if got != want {
t.Errorf("got %q want %q", got, want)
}
}