2023-09-29 10:07:31 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestHello(t *testing.T) {
|
2023-09-29 10:15:35 -04:00
|
|
|
t.Run("saying hello to people", func(t *testing.T) {
|
|
|
|
got := Hello("Chris")
|
|
|
|
want := "Hello, Chris"
|
|
|
|
assertCorrectMessage(t, got, want)
|
|
|
|
})
|
|
|
|
t.Run("say 'Hello, World' when an empty string is supplied", func(t *testing.T) {
|
|
|
|
got := Hello("")
|
|
|
|
want := "Hello, World"
|
|
|
|
assertCorrectMessage(t, got, want)
|
|
|
|
})
|
|
|
|
}
|
2023-09-29 10:07:31 -04:00
|
|
|
|
2023-09-29 10:15:35 -04:00
|
|
|
func assertCorrectMessage(t testing.TB, got, want string) {
|
|
|
|
t.Helper()
|
2023-09-29 10:07:31 -04:00
|
|
|
if got != want {
|
|
|
|
t.Errorf("got %q want %q", got, want)
|
|
|
|
}
|
|
|
|
}
|