-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcases_test.go
More file actions
78 lines (77 loc) · 1.08 KB
/
cases_test.go
File metadata and controls
78 lines (77 loc) · 1.08 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
package luhn
var testCases = []struct {
description string
input string
ok bool
}{
{
"single digit string can not be valid",
"1",
false,
},
{
"a single zero is invalid",
"0",
false,
},
{
"a simple valid SIN that remains valid if reversed",
"059",
true,
},
{
"a simple valid SIN that becomes invalid if reversed",
"59",
true,
},
{
"a valid Canadian SIN",
"055 444 285",
true,
},
{
"invalid Canadian SIN",
"055 444 286",
false,
},
{
"invalid credit card",
"8273 1232 7352 0569",
false,
},
{
"valid number with an even number of digits",
"095 245 88",
true,
},
{
"valid string with a non-digit added at the end to become invalid",
"059a",
false,
},
{
"valid string with punctuation included become invalid",
"055-444-285",
false,
},
{
"valid string with symbols included become invalid",
"055% 444% 285",
false,
},
{
"single zero with space is invalid",
" 0",
false,
},
{
"more than a single zero is valid",
"0000 0",
true,
},
{
"string with non-digit is invalid",
":9",
false,
},
}