| 12345678910111213141516171819202122232425 |
- package greetings
- import (
- "regexp"
- "testing"
- )
- // TestHelloName chama greetings.Hello com um nome, verificando um valor de retorno válido.
- func TestHelloName(t *testing.T) {
- name := "Gladys"
- want := regexp.MustCompile(`\b` + name + `\b`)
- msg := Hello(name)
- if !want.MatchString(msg) {
- t.Fatalf(`Hello("Gladys") = %q, want match for %#q, nil`, msg, want)
- }
- }
- // TestHelloEmpty chama greetings.Hello com uma string vazia, verificando um erro.
- func TestHelloEmpty(t *testing.T) {
- name := ""
- msg := Hello(name)
- if msg == "" {
- t.Fatalf(`Hello("") = %q, want non-empty string`, msg)
- }
- }
|