forked from Pallinder/go-randomdata
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostalcodes_test.go
More file actions
54 lines (49 loc) · 731 Bytes
/
postalcodes_test.go
File metadata and controls
54 lines (49 loc) · 731 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
42
43
44
45
46
47
48
49
50
51
52
53
54
package randomdata
import (
"testing"
)
var postalcodeTests = []struct {
Country string
Size int
}{
{"PE", 6},
{"FO", 6},
{"AF", 4},
{"DZ", 5},
{"BY", 6},
{"CL", 7},
{"SZ", 4},
{"BM", 4},
{"AD", 5},
{"BN", 6},
{"BB", 7},
{"MT", 7},
{"JM", 7},
{"AR", 8},
{"CA", 6},
{"FK", 7},
{"GG", 6},
{"NL", 6},
{"BR", 9},
{"KY", 8},
{"JP", 8},
{"LV", 7},
{"LT", 8},
{"MV", 5},
{"NI", 9},
{"PL", 6},
{"PT", 8},
{"KR", 7},
{"TW", 5},
{"MH", 5},
}
func TestPostalCode(t *testing.T) {
for _, pt := range postalcodeTests {
code := PostalCode(pt.Country)
if len(code) == pt.Size {
continue
}
t.Fatalf("Invalid length for country %q: Expected %d, have %d.",
pt.Country, pt.Size, len(code))
}
}