-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheinvalidator_test.go
More file actions
51 lines (48 loc) · 1.2 KB
/
Copy patheinvalidator_test.go
File metadata and controls
51 lines (48 loc) · 1.2 KB
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
package einvalidator
import (
"testing"
)
func TestValidate(t *testing.T) {
einV := New()
cases := []struct {
ein string
valid bool
}{
{"20-0000000", true},
{"20 0000000", true},
{"200000000", true},
{"20x0000000", false}, // invalid seperator
{"97-9999999", false}, // invalid prefix
{"", false}, // no ein passed
{"00", false}, // only prefix passed
{"not a valid EIN", false}, // not even close to EIN passed
}
for _, c := range cases {
valid, err := einV.Validate(c.ein)
if c.valid != valid {
t.Errorf("failed to validate: %s should be %t, but received error %s", c.ein, c.valid, err)
}
}
}
func TestMask(t *testing.T) {
einV := New()
cases := []struct {
ein string
mask string
}{
{"20-0000000", "XX-XXXXX00"},
{"20 0000000", "XX XXXXX00"},
{"200000000", "XXXXXXX00"},
{"20y0000000", ""}, // invalid seperator
{"97-9999999", ""}, // invalid prefix
{"", ""}, // no ein passed
{"00", ""}, // only prefix passed
{"not a valid EIN", ""}, // not even close to EIN passed
}
for _, c := range cases {
mask, err := einV.Mask(c.ein)
if c.mask != mask {
t.Errorf("failed to validate: %s should be %s, but received error %s", c.ein, c.mask, err)
}
}
}