-
Notifications
You must be signed in to change notification settings - Fork 0
/
postal_test.go
82 lines (70 loc) · 1.8 KB
/
postal_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package dirsyn
import (
"testing"
)
func TestDeliveryMethod(t *testing.T) {
var r RFC4517
for _, raw := range []string{
`any`,
`mhs $ g3fax $ ia5 $ telephone`,
} {
if dm, err := r.DeliveryMethod(raw); err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
} else if got := dm.String(); got != raw {
t.Errorf("%s failed:\nwant: %s\ngot: %s",
t.Name(), raw, got)
}
}
}
func TestPostalAddress(t *testing.T) {
var r RFC4517
for _, raw := range []string{
`123 Fake Street$Palm Springs$CA$92111`,
`The \$100000 Sweepstakes$10 Million Dollar Avenue$New York$NY`,
`104 West Fake Street$Unit #10$Nowhere$MA$01234$US`,
} {
if pa, err := r.PostalAddress(raw); err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
} else if got := pa.String(); got != raw {
t.Errorf("%s failed:\nwant: %s\ngot: %s",
t.Name(), raw, got)
}
}
}
func TestOtherMailbox(t *testing.T) {
var r RFC4517
for _, raw := range []string{
`other$mailbox`,
`test+,+$mailbox`,
} {
if _, err := r.OtherMailbox(raw); err != nil {
t.Errorf("%s failed: %v", t.Name(), err)
}
}
r.OtherMailbox(`界ac`)
}
func TestPostal_codecov(t *testing.T) {
pSOrIA5s(nil)
pSOrIA5s(`\\$`)
pSOrIA5s(string(rune(0)))
pSOrIA5s(string(rune(14)))
pSOrIA5s(`\$`)
pSOrIA5s(`......\$....!`)
pSOrIA5s(`......\\$....!`)
pSOrIA5s("......\\$....!")
pSOrIA5s(`.$.$.$.$.$`)
pSOrIA5s(`.$.$@$#$.$`)
pSOrIA5s(`界界界`)
pSOrIA5s(`界$界$界`)
pSOrIA5s(`$100000 Sweepstakes$10 Million Dollar Avenue$New York$NY`)
deliveryMethod(nil)
postalAddress(nil)
otherMailbox(nil)
_ = printableString(`Hello.`)
lineChar(`.#.$.$.$$`)
lineChar(`.#.naïve.$.$$`)
lineChar(string(rune('\U0010AAAA')) + `ð`)
lineChar(`$a\\bc$界$`)
lineChar(string([]rune{'\u00e0', '$', '\u00FF'}))
lineChar(string([]rune{'\u00e0', '$', '\uFFFF'}))
}