new exporter version
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
module main.go
|
||||
|
||||
go 1.25.5
|
||||
@@ -0,0 +1,33 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
const Prefix = "Hello "
|
||||
|
||||
func Hello(name,language string) string {
|
||||
if name == "" {
|
||||
name = "world"
|
||||
}
|
||||
if language == "Russian" {
|
||||
return "Привет " + name
|
||||
}
|
||||
return Prefix + name
|
||||
}
|
||||
func main() {
|
||||
fmt.Println(Hello("Utii",""))
|
||||
}
|
||||
Reference in New Issue
Block a user