+16
Go/.editorconfig
+16
Go/.editorconfig
···
1
+
2
+
3
+
# EditorConfig is awesome: https://EditorConfig.org
4
+
5
+
# top-most EditorConfig file
6
+
root = true
7
+
8
+
# Unix-style newlines with a newline ending every file
9
+
[*.go]
10
+
end_of_line = lf
11
+
insert_final_newline = true
12
+
charset = utf-8
13
+
indent_style = space
14
+
indent_size = 4
15
+
trim_trailing_whitespace = true
16
+
insert_final_newline = true
+13
-10
Go/hello_test.go
+13
-10
Go/hello_test.go
···
4
4
5
5
func TestHello(t *testing.T) {
6
6
t.Run("saying hello to people", func(t *testing.T) {
7
-
got := Hello("Pedro")
8
-
want := "Hello, Pedro"
7
+
got := Hello("Pedro")
8
+
want := "Hello, Pedro"
9
9
10
-
if got != want {
11
-
t.Errorf("got %q want %q", got, want)
12
-
}
10
+
assertCorrectMessage(t, got, want)
13
11
})
14
12
15
13
t.Run("say 'Hello, world' when an empty string is supplied", func(t *testing.T) {
16
-
got := Hello("")
17
-
want := "Hello, world"
14
+
got := Hello("")
15
+
want := "Hello, world"
18
16
19
-
if got != want {
20
-
t.Errorf("got %q want %q", got, want)
21
-
}
17
+
assertCorrectMessage(t, got, want)
22
18
})
23
19
}
24
20
21
+
func assertCorrectMessage(t testing.TB, got, want string) {
22
+
// this tells the test suite this method is a helper
23
+
t.Helper()
24
+
if got != want {
25
+
t.Errorf("got %q want %q", got, want)
26
+
}
27
+
}