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 0368b85 · on main · k33g · 2h ago
hello_test.go · 26 lines · 768 BGo Blame HistoryRaw
 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
package hello

import "testing"

func TestGreet(t *testing.T) {
	cases := []struct {
		why  string
		name string
		want string
	}{
		{"a name is greeted as it is written", "Bob", "Hello, Bob!"},
		{"surrounding whitespace is not part of a name", "  Bob\t", "Hello, Bob!"},
		{"an empty name still produces a whole greeting", "", "Hello, world!"},
		{"a name of nothing but whitespace is an empty name", "   ", "Hello, world!"},
		{"the inside of a name is left alone", "Ada Lovelace", "Hello, Ada Lovelace!"},
		{"a name is not assumed to be ASCII", "Émilie", "Hello, Émilie!"},
	}

	for _, c := range cases {
		t.Run(c.why, func(t *testing.T) {
			if got := Greet(c.name); got != c.want {
				t.Errorf("Greet(%q) = %q, want %q", c.name, got, c.want)
			}
		})
	}
}