Move from learn-go-with-tests
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
18bde5d382
commit
b7c3fffbaa
10 changed files with 213 additions and 0 deletions
34
learn-go-with-tests/hello_test.go
Normal file
34
learn-go-with-tests/hello_test.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHello(t *testing.T) {
|
||||
assertCorrectMessage := func(t testing.TB, got string, want string) {
|
||||
t.Helper()
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %q want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
t.Run("saying hello to people", func (t *testing.T) {
|
||||
got := Hello("Oliver", "")
|
||||
want := "Hello, Oliver"
|
||||
|
||||
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 Welsh", func (t *testing.T) {
|
||||
got := Hello("Oliver", "Welsh")
|
||||
want := "Helo, Oliver"
|
||||
|
||||
assertCorrectMessage(t, got, want)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue