-
Notifications
You must be signed in to change notification settings - Fork 141
/
address_test.go
33 lines (30 loc) · 804 Bytes
/
address_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)
}
}
}