bots-garden/hellopublic Fork 0
main
Commits
Clone
git clone https://git.rickub.com/bots-garden/hello.git
git clone ssh://git@rickub.com/bots-garden/hello.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

hello_test.go · 26 lines · 768 BGo Blame HistoryRaw
📦 Hello 0368b85 k33g 3h ago1package hello
2
3import "testing"
4
5func TestGreet(t *testing.T) {
6 cases := []struct {
7 why string
8 name string
9 want string
10 }{
11 {"a name is greeted as it is written", "Bob", "Hello, Bob!"},
12 {"surrounding whitespace is not part of a name", " Bob\t", "Hello, Bob!"},
13 {"an empty name still produces a whole greeting", "", "Hello, world!"},
14 {"a name of nothing but whitespace is an empty name", " ", "Hello, world!"},
15 {"the inside of a name is left alone", "Ada Lovelace", "Hello, Ada Lovelace!"},
16 {"a name is not assumed to be ASCII", "Émilie", "Hello, Émilie!"},
17 }
18
19 for _, c := range cases {
20 t.Run(c.why, func(t *testing.T) {
21 if got := Greet(c.name); got != c.want {
22 t.Errorf("Greet(%q) = %q, want %q", c.name, got, c.want)
23 }
24 })
25 }
26}