-
Notifications
You must be signed in to change notification settings - Fork 5
/
cpf_test.go
103 lines (78 loc) · 1.75 KB
/
cpf_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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package cpfcnpj
import (
"testing"
)
func TestValidCPFWithValidNumber1(t *testing.T) {
r := ValidateCPF("64844696793")
if !r {
t.Errorf("Invalid result: %v", r)
}
}
func TestValidCPFWithValidNumber2(t *testing.T) {
r := ValidateCPF("62641322846")
if !r {
t.Errorf("Invalid result: %v", r)
}
}
func TestValidCPFWithValidNumber3(t *testing.T) {
r := ValidateCPF("87195726037")
if !r {
t.Errorf("Invalid result: %v", r)
}
}
func TestValidCPFWithValidNumber4(t *testing.T) {
r := ValidateCPF("71656686759")
if !r {
t.Errorf("Invalid result: %v", r)
}
}
func TestValidCPFWithInvalidNumber1(t *testing.T) {
r := ValidateCPF("71656686753")
if r {
t.Errorf("Invalid result: %v", r)
}
}
func TestValidCPFWithInvalidNumber2(t *testing.T) {
r := ValidateCPF("71656686739")
if r {
t.Errorf("Invalid result: %v", r)
}
}
func TestValidCPFWithInvalidNumber3(t *testing.T) {
r := ValidateCPF("71656686734")
if r {
t.Errorf("Invalid result: %v", r)
}
}
func TestCPFTypeIsValidWithValidNumber(t *testing.T) {
var cpf CPF = "71656686759"
if !cpf.IsValid() {
t.Errorf("Invalid result: false")
}
}
func TestCPFTypeIsValidWithInvalidNumber(t *testing.T) {
var cpf CPF = "71656686734"
if cpf.IsValid() {
t.Errorf("Invalid result: true")
}
}
func TestCPFTypeStringFormattingWithValidNumber(t *testing.T) {
var cpf CPF = "71656686759"
r := cpf.String()
if r != "716.566.867-59" {
t.Errorf("Invalid result: %v", r)
}
}
func TestCPFTypeStringFormattingWithInvalidNumber(t *testing.T) {
var cpf CPF = "71656686734"
r := cpf.String()
if r != "71656686734" {
t.Errorf("Invalid result: %v", r)
}
}
func TestCPFNewCPF(t *testing.T) {
cpf := NewCPF("716.566.867-59")
if cpf != "71656686759" {
t.Errorf("Invalid result: %v", cpf)
}
}