forked from Spokepoint/smtp-callback-verification
-
Notifications
You must be signed in to change notification settings - Fork 1
/
smtp_test.go
57 lines (48 loc) · 1014 Bytes
/
smtp_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
package main
import (
"testing"
)
type testpair struct {
email string
valid bool
}
var tests = []testpair{
{"[email protected]", true},
{"[email protected]", true},
{"[email protected]", false},
{"not an email", false},
}
func TestVerifyEmail(t *testing.T) {
for _, pair := range tests {
v, err := VerifyEmail(pair.email)
if v != pair.valid {
t.Error(
"Error Message:", err,
". For", pair.email,
"expected", pair.valid,
"got", v,
)
}
}
}
///// Benchmarks /////
func BenchmarkVerifyEmail_Found(b *testing.B) {
for i := 0; i < b.N; i++ {
VerifyEmail("[email protected]")
}
}
func BenchmarkVerifyEmail_Capitalised(b *testing.B) {
for i := 0; i < b.N; i++ {
VerifyEmail("[email protected]")
}
}
func BenchmarkVerifyEmail_NotFound(b *testing.B) {
for i := 0; i < b.N; i++ {
VerifyEmail("[email protected]")
}
}
func BenchmarkVerifyEmail_Blank(b *testing.B) {
for i := 0; i < b.N; i++ {
VerifyEmail("")
}
}