-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevalidate_test.go
46 lines (40 loc) · 961 Bytes
/
evalidate_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
34
35
36
37
38
39
40
41
42
43
44
45
46
package evalidate_test
import (
"testing"
evalidate "github.com/kumarabd/go-email-validation"
)
var (
samples = []struct {
mail string
format bool
account bool //host+user
}{
{mail: "[email protected]", format: true, account: true},
{mail: "[email protected]", format: true, account: false},
}
)
func TestValidateHost(t *testing.T) {
for _, s := range samples {
if !s.format {
continue
}
err := evalidate.ValidateHost(s.mail)
if err != nil && s.account == true {
t.Errorf(`"%s" => host error: "%v"`, s.mail, err)
}
if err == nil && s.account == false {
t.Errorf(`"%s" => account error`, s.mail)
}
}
}
func TestValidateFormat(t *testing.T) {
for _, s := range samples {
err := evalidate.ValidateFormat(s.mail)
if err != nil && s.format == true {
t.Errorf(`"%s" => validate error: "%v"`, s.mail, err)
}
if err == nil && s.format == false {
t.Errorf(`"%s" => format error`, s.mail)
}
}
}