Files
2020-12-21 15:43:22 +08:00

34 lines
804 B
Go

package emailverifier
import (
"testing"
)
var (
samples = []struct {
mail string
format bool
}{
{mail: "[email protected]", format: true},
{mail: "[email protected]", format: true},
{mail: " [email protected]", format: false},
{mail: "[email protected]", format: true},
{mail: "😀@gmail.com", format: false},
{mail: "[email protected]", format: true},
{mail: "[email protected]", format: true},
{mail: "abc@доменное.com", format: true},
}
)
func TestCheckAddressSyntax(t *testing.T) {
for _, s := range samples {
address := verifier.ParseAddress(s.mail)
if !address.Valid && s.format == true {
t.Errorf(`"%s" check failed with an unexpected error`, s.mail)
}
if address.Valid && s.format == false {
t.Errorf(`"%s" => incorrect email address`, s.mail)
}
}
}