-
Notifications
You must be signed in to change notification settings - Fork 0
/
truemail_test.go
40 lines (36 loc) · 960 Bytes
/
truemail_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
package truemail_test
import (
"testing"
"github.com/H-Richard/truemail"
)
func TestValidate(t *testing.T) {
tests := []struct {
email string
expected error
}{
{email: "", expected: truemail.ErrFor},
{email: "@", expected: truemail.ErrFor},
}
v := truemail.Validator{}
for _, c := range tests {
if actual := v.Validate(c.email); actual != c.expected {
t.Errorf("Test failed for %s\nexpected: %s\nactual: %s", c.email, c.expected, actual)
}
}
}
func TestInvalidDomainFormat(t *testing.T) {
tests := []struct {
email string
expected error
}{
{email: "richard@aaaa", expected: truemail.ErrFor},
{email: "richard@bbbbb,", expected: truemail.ErrFor},
{email: "richard@bbbbb.,", expected: truemail.ErrFor},
}
v := truemail.Validator{}
for _, c := range tests {
if actual := v.Validate(c.email); actual != c.expected {
t.Errorf("Test failed for %s\nexpected: %s\nactual: %s", c.email, c.expected, actual)
}
}
}