-
Notifications
You must be signed in to change notification settings - Fork 1
/
document_test.go
47 lines (42 loc) · 965 Bytes
/
document_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
package Document
import "testing"
func TestValidateCPF(t *testing.T) {
tests := []struct {
cpf string
expected bool
}{
{"abcdefghijk", false},
{"123", false},
{"", false},
{"12345678900", false},
{"95524361503", true},
{"955.243.615-03", true},
{" 955 243 615 03 ", true},
}
for _, tt := range tests {
actual := ValidateCPF(tt.cpf)
if actual != tt.expected {
t.Errorf("ValidateCPF(%s): expected %t, but got %t", tt.cpf, tt.expected, actual)
}
}
}
func TestValidateCNPJ(t *testing.T) {
tests := []struct {
cnpj string
expected bool
}{
{"abcdefghijklmn", false},
{"123", false},
{"", false},
{"12345678901234", false},
{"11222333000181", true},
{"11.222.333/0001-81", true},
{" 11 222 333 0001 81 ", true},
}
for _, tt := range tests {
actual := ValidateCNPJ(tt.cnpj)
if actual != tt.expected {
t.Errorf("ValidateCNPJ(%s): expected %t, but got %t", tt.cnpj, tt.expected, actual)
}
}
}