Added plan of tests

This commit is contained in:
Alexander Pivkin
2025-12-20 09:59:10 +03:00
parent 4833874324
commit a889e1c7dd
7 changed files with 58 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
module main.go
go 1.24.5
+33
View File
@@ -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)
}
}
+18
View File
@@ -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",""))
}