-
Notifications
You must be signed in to change notification settings - Fork 219
/
parse_test.go
44 lines (41 loc) · 1.15 KB
/
parse_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
package smtp
import (
"testing"
)
func TestParser(t *testing.T) {
validReversePaths := []struct {
raw, path, after string
}{
{"<>", "", ""},
{"<[email protected]>", "[email protected]", ""},
{"[email protected]", "[email protected]", ""},
}
for _, tc := range validReversePaths {
p := parser{tc.raw}
path, err := p.parseReversePath()
if err != nil {
t.Errorf("parser.parseReversePath(%q) = %v", tc.raw, err)
} else if path != tc.path {
t.Errorf("parser.parseReversePath(%q) = %q, want %q", tc.raw, path, tc.path)
} else if p.s != tc.after {
t.Errorf("parser.parseReversePath(%q): got after = %q, want %q", tc.raw, p.s, tc.after)
}
}
invalidReversePaths := []string{
"",
" ",
"asdf",
"<Foo Bar <[email protected]>>",
" BODY=8BITMIME SIZE=12345",
"a:b:[email protected]",
}
for _, tc := range invalidReversePaths {
p := parser{tc}
if path, err := p.parseReversePath(); err == nil {
t.Errorf("parser.parseReversePath(%q) = %q, want error", tc, path)
}
}
}