-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpf_test.go
More file actions
107 lines (93 loc) · 1.75 KB
/
Copy pathcpf_test.go
File metadata and controls
107 lines (93 loc) · 1.75 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
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
104
105
106
107
package cpf
import (
"strconv"
"testing"
)
func TestValidWithDots(t *testing.T) {
v := Valid("886.100.254-46")
if v != true {
t.Error("Expected true, got", v)
}
}
func TestValidWithoutDots(t *testing.T) {
v := Valid("88610025446")
if v != true {
t.Error("Expected true, got", v)
}
}
func TestShortWithDots(t *testing.T) {
v := Valid("123.123.123")
if v != false {
t.Error("Expected false, got", v)
}
}
func TestShortWithoutDots(t *testing.T) {
v := Valid("123123123")
if v != false {
t.Error("Expected false, got", v)
}
}
func TestLongWithDots(t *testing.T) {
v := Valid("123.123.123.12-12")
if v != false {
t.Error("Expected false, got", v)
}
}
func TestLongWithoutDots(t *testing.T) {
v := Valid("123123123123")
if v != false {
t.Error("Expected false, got", v)
}
}
func TestInValidWithDots(t *testing.T) {
v := Valid("123.123.123.12")
if v != false {
t.Error("Expected false, got", v)
}
}
func TestInValidWithoutDots(t *testing.T) {
v := Valid("12312312312")
if v != false {
t.Error("Expected false, got", v)
}
}
func TestInValidSameNumbersWithDots(t *testing.T) {
var n string
var v bool
for i := 1; i <= 9; i++ {
n = ""
for x := 1; x <= 11; x++ {
n += strconv.Itoa(i)
}
v = Valid(n)
if v != false {
t.Errorf("Expected false, got %v for %v", v, n)
}
}
}
func TestInValidSameNumbersWithoutDots(t *testing.T) {
var n string
var v bool
for i := 1; i <= 9; i++ {
n = ""
for x := 1; x <= 11; x++ {
if x == 4 || x == 7 {
n += "."
}
if x == 10 {
n += "-"
}
n += strconv.Itoa(i)
}
v = Valid(n)
if v != false {
t.Errorf("Expected false, got %v for %v", v, n)
}
}
}
func TestInvalidEmpty(t *testing.T) {
v := Valid("")
if v != false {
t.Error("Expected false, got", v)
}
}