hello_test: create an assert function
This commit is contained in:
parent
5e32007c89
commit
f593fb28de
@ -6,16 +6,19 @@ func TestHello(t *testing.T) {
|
||||
t.Run("Hello someone", func(t *testing.T) {
|
||||
got := Hello("Jason")
|
||||
exp := "Hello Jason"
|
||||
if got != exp {
|
||||
t.Errorf("got %q expected %q", got, exp)
|
||||
}
|
||||
assertCorrectMsg(t, got, exp)
|
||||
})
|
||||
|
||||
t.Run("Hello default", func(t *testing.T) {
|
||||
got := Hello("")
|
||||
exp := "Hello world"
|
||||
assertCorrectMsg(t, got, exp)
|
||||
})
|
||||
}
|
||||
|
||||
func assertCorrectMsg(t testing.TB, got, exp string) {
|
||||
t.Helper()
|
||||
if got != exp {
|
||||
t.Errorf("got %q expected %q", got, exp)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user