-
Notifications
You must be signed in to change notification settings - Fork 7
/
hello_test.go
41 lines (38 loc) · 920 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
package gorepotemplate
import "testing"
// TestHello tests that the Hello function produces the expected greeting.
func TestHello(t *testing.T) {
testCases := []struct {
TestCaseName string
Name string
ExpectedGreeting string
}{
{
TestCaseName: "All lowercase name",
Name: "cpu",
ExpectedGreeting: "Hello cpu",
},
{
TestCaseName: "All uppercase name",
Name: "CPU",
ExpectedGreeting: "Hello cpu",
},
{
TestCaseName: "Mixed case name",
Name: "cPu",
ExpectedGreeting: "Hello cpu",
},
{
TestCaseName: "No name",
ExpectedGreeting: "Hello",
},
}
for _, tc := range testCases {
t.Run(tc.TestCaseName, func(t *testing.T) {
if greeting := Hello(tc.Name); greeting != tc.ExpectedGreeting {
t.Errorf("hello(%q) returned %q not %q",
tc.Name, greeting, tc.ExpectedGreeting)
}
})
}
}