-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail_test.go
60 lines (56 loc) · 2.04 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package is
import (
"testing"
"github.com/goloop/g"
)
// TestEmail tests the Email function.
func TestEmail(t *testing.T) {
// Test cases.
tests := map[string]bool{
"": false,
"[email protected]": false,
"[email protected]": false,
"[email protected]": false,
"[email protected]": false,
"[email protected]": false,
"!def!xyz%[email protected]": false,
"[email protected]": false,
"[email protected]": false,
"[email protected]": false,
"[email protected]": false,
"[email protected]": false,
"0932910@example@com": false,
"0932910@com": false,
"[email protected] ": false,
" [email protected]": false,
"@example.com": false,
"test@[email protected]": false,
"test@wrong domain.com": false,
"é&ààà@example.com": false,
"not-a-valid-email": false,
"test [email protected]": false,
"michel @example.com": false,
"[email protected]": false,
g.Trim(" [email protected] "): true,
g.Weed("twolines\[email protected]\n"): true,
"[email protected]": true,
"[email protected]": true,
"[email protected]": true,
"[email protected]": true,
"[email protected]": true,
"[email protected]": true,
"[email protected]": true,
"[email protected]": true,
"2023@знищена-московія.укр": true,
"プーチンはクソだ@example.com": true,
"二ノ宮@黒川.日本": true,
"我買@屋企.香港": true,
}
for k, v := range tests {
result := Email(k)
if result != v {
t.Errorf("Email(\"%v\"): expected %v, but got %v",
k, v, result)
}
}
}