-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_test.go
More file actions
41 lines (35 loc) · 832 Bytes
/
main_test.go
File metadata and controls
41 lines (35 loc) · 832 Bytes
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
package main
import (
"testing"
)
func TestSplitEmailAddress(t *testing.T){
testCases := []struct {
input string
userPart string
domainPart string
hasError bool
}{
{
"foobar",
"",
"",
true,
},{
"mail@fleaz.me",
"mail",
"fleaz.me",
false,
},{
"valid@address@it.cyber.org",
"valid@address",
"it.cyber.org",
false,
},
}
for _,entry := range testCases{
user,domain,err := splitEmailAddress(entry.input)
if (user != entry.userPart) || (domain != entry.domainPart) || ((err!=nil) != entry.hasError){
t.Errorf("splitEmailAddress failed for %q", entry.input)
}
}
}