-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_test.go
38 lines (30 loc) · 987 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
package main
import "testing"
func TestGetWhatToSay(t *testing.T) {
assertString := func(t testing.TB, given string, expected string) {
t.Helper()
if given != expected {
t.Errorf("got %q want %q", given, expected)
}
}
t.Run("Should say hello world if no string is supplied", func(t *testing.T) {
given := getWhatToSay("", "English")
expected := "Hello, 'World'.\n"
assertString(t, given, expected)
})
t.Run("Should say hello to people", func(t *testing.T) {
given := getWhatToSay("Patrick", "English")
expected := "Hello, 'Patrick'.\n"
assertString(t, given, expected)
})
t.Run("Should say hello to people in german", func(t *testing.T) {
given := getWhatToSay("Patrick", "German")
expected := "Hallo, 'Patrick'.\n"
assertString(t, given, expected)
})
t.Run("Should say hello to people in french", func(t *testing.T) {
given := getWhatToSay("Patrick", "French")
expected := "Bonjour, 'Patrick'.\n"
assertString(t, given, expected)
})
}