34 lines
819 B
Go
34 lines
819 B
Go
package helloworld
|
|
|
|
import "testing"
|
|
|
|
func TestHello(t *testing.T) {
|
|
t.Run("saying helloworld 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)
|
|
})
|
|
t.Run("in Spanish", func(t *testing.T) {
|
|
got := Hello("Elodie", "Spanish")
|
|
want := "Hola, Elodie"
|
|
assertCorrectMessage(t, got, want)
|
|
})
|
|
t.Run("in French", func(t *testing.T) {
|
|
got := Hello("Elise", "French")
|
|
want := "Bonjour, Elise"
|
|
assertCorrectMessage(t, got, want)
|
|
})
|
|
}
|
|
|
|
func assertCorrectMessage(t testing.TB, got, want string) {
|
|
t.Helper()
|
|
if got != want {
|
|
t.Errorf("got %q want %q", got, want)
|
|
}
|
|
}
|