-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathemail_test.go
39 lines (35 loc) · 931 Bytes
/
email_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
package Validator
import (
"testing"
)
var validEmails = []string{
}
var invalidEmails = []string{
"",
"test",
"test.com",
".com",
"адрес@пример.рф",
"space [email protected]",
"newline\[email protected]",
"asyouallcanseethisemailaddressexceedsthemaximumnumberofcharactersallowedtobeintheemailaddresswhichisnomorethatn254accordingtovariousrfcokaycanistopnowornotyetnoineedmorecharacterstoadd@i.really.cannot.thinkof.what.else.to.put.into.this.invalid.address.net",
}
func TestIsValidEmail(t *testing.T) {
for i, v := range validEmails {
if !IsValidEmail(v) {
t.Errorf("%d: didn't accept valid email: %s", i, v)
}
}
for i, v := range invalidEmails {
if IsValidEmail(v) {
t.Errorf("%d: accepted invalid email: %s", i, v)
}
}
}