learning_go/testing/helloworld/hello_test.go
2025-12-20 09:59:10 +03:00

34 lines
630 B
Go

package main
import "testing"
func TestHello(t *testing.T) {
t.Run("Say hi to Utii",func(t *testing.T) {
got := Hello("Utii","")
want := "Hello Utii"
assertCorrestMsg(t,got,want)
})
t.Run("say 'Hello world' when arg is empty",func(t *testing.T){
got := Hello("","")
want := "Hello world"
assertCorrestMsg(t,got,want)
})
t.Run("say 'Hello world' in Russian",func(t *testing.T){
got := Hello("Utii","Russian")
want := "Привет Utii"
assertCorrestMsg(t,got,want)
})
}
func assertCorrestMsg(t testing.TB,got, want string) {
t.Helper()
if got != want {
t.Errorf("got %q want %q",got,want)
}
}