This repository has been archived by the owner on Nov 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_regex.py
162 lines (152 loc) · 9.33 KB
/
test_regex.py
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import npbc_regex
def test_regex_number():
assert npbc_regex.NUMBER_MATCH_REGEX.match('') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('1') is not None
assert npbc_regex.NUMBER_MATCH_REGEX.match('1 2') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('1-2') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('11') is not None
assert npbc_regex.NUMBER_MATCH_REGEX.match('11-12') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('11-12,13') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('11-12,13-14') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('111') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('a') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('1a') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('1a2') is None
assert npbc_regex.NUMBER_MATCH_REGEX.match('12b') is None
def test_regex_range():
assert npbc_regex.RANGE_MATCH_REGEX.match('') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('1') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('1 2') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('1-2') is not None
assert npbc_regex.RANGE_MATCH_REGEX.match('11') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('11-') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('11-12') is not None
assert npbc_regex.RANGE_MATCH_REGEX.match('11-12-1') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('11 -12') is not None
assert npbc_regex.RANGE_MATCH_REGEX.match('11 - 12') is not None
assert npbc_regex.RANGE_MATCH_REGEX.match('11- 12') is not None
assert npbc_regex.RANGE_MATCH_REGEX.match('11-2') is not None
assert npbc_regex.RANGE_MATCH_REGEX.match('11-12,13') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('11-12,13-14') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('111') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('a') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('1a') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('1a2') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('12b') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('11-a') is None
assert npbc_regex.RANGE_MATCH_REGEX.match('11-12a') is None
def test_regex_CSVs():
assert npbc_regex.CSV_MATCH_REGEX.match('') is None
assert npbc_regex.CSV_MATCH_REGEX.match('1') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('a') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('adcef') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('-') is not None
assert npbc_regex.CSV_MATCH_REGEX.match(' ') is None
assert npbc_regex.CSV_MATCH_REGEX.match('1,2') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('1-3') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('monday') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('monday,tuesday') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('mondays') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('tuesdays') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('1,2,3') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('1-3') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('monday,tuesday') is not None
assert npbc_regex.CSV_MATCH_REGEX.match('mondays,tuesdays') is not None
assert npbc_regex.CSV_MATCH_REGEX.match(';') is None
assert npbc_regex.CSV_MATCH_REGEX.match(':') is None
assert npbc_regex.CSV_MATCH_REGEX.match(':') is None
assert npbc_regex.CSV_MATCH_REGEX.match('!') is None
assert npbc_regex.CSV_MATCH_REGEX.match('1,2,3,4') is not None
def test_regex_days():
assert npbc_regex.DAYS_MATCH_REGEX.match('') is None
assert npbc_regex.DAYS_MATCH_REGEX.match('1') is None
assert npbc_regex.DAYS_MATCH_REGEX.match('1,2') is None
assert npbc_regex.DAYS_MATCH_REGEX.match('1-3') is None
assert npbc_regex.DAYS_MATCH_REGEX.match('monday') is None
assert npbc_regex.DAYS_MATCH_REGEX.match('monday,tuesday') is None
assert npbc_regex.DAYS_MATCH_REGEX.match('mondays') is not None
assert npbc_regex.DAYS_MATCH_REGEX.match('tuesdays') is not None
def test_regex_n_days():
assert npbc_regex.N_DAY_MATCH_REGEX.match('') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('1') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('1-') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('1,2') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('1-3') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('monday') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('monday,tuesday') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('mondays') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('1-tuesday') is not None
assert npbc_regex.N_DAY_MATCH_REGEX.match('11-tuesday') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('111-tuesday') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('11-tuesdays') is None
assert npbc_regex.N_DAY_MATCH_REGEX.match('1 -tuesday') is not None
assert npbc_regex.N_DAY_MATCH_REGEX.match('1- tuesday') is not None
assert npbc_regex.N_DAY_MATCH_REGEX.match('1 - tuesday') is not None
def test_regex_all_text():
assert npbc_regex.ALL_MATCH_REGEX.match('') is None
assert npbc_regex.ALL_MATCH_REGEX.match('1') is None
assert npbc_regex.ALL_MATCH_REGEX.match('1-') is None
assert npbc_regex.ALL_MATCH_REGEX.match('1,2') is None
assert npbc_regex.ALL_MATCH_REGEX.match('1-3') is None
assert npbc_regex.ALL_MATCH_REGEX.match('monday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('monday,tuesday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('mondays') is None
assert npbc_regex.ALL_MATCH_REGEX.match('tuesdays') is None
assert npbc_regex.ALL_MATCH_REGEX.match('1-tuesday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('11-tuesday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('111-tuesday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('11-tuesdays') is None
assert npbc_regex.ALL_MATCH_REGEX.match('1 -tuesday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('1- tuesday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('1 - tuesday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('all') is not None
assert npbc_regex.ALL_MATCH_REGEX.match('all,tuesday') is None
assert npbc_regex.ALL_MATCH_REGEX.match('all,tuesdays') is None
assert npbc_regex.ALL_MATCH_REGEX.match('All') is not None
assert npbc_regex.ALL_MATCH_REGEX.match('AlL') is not None
assert npbc_regex.ALL_MATCH_REGEX.match('ALL') is not None
def test_delivery_regex():
assert npbc_regex.DELIVERY_MATCH_REGEX.match('') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('a') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('1') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('1.') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('1.5') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('1,2') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('1-2') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('1;2') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('1:2') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('1,2,3') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('Y') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('N') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YY') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YYY') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YYYY') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YYYYY') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YYYYYY') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YYYYYYY') is not None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YYYYYYYY') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('NNNNNNN') is not None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('NYNNNNN') is not None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('NYYYYNN') is not None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('NYYYYYY') is not None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('NYYYYYYY') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('N,N,N,N,N,N,N') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('N;N;N;N;N;N;N') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('N-N-N-N-N-N-N') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('N N N N N N N') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YYYYYYy') is None
assert npbc_regex.DELIVERY_MATCH_REGEX.match('YYYYYYn') is None
def test_regex_hyphen():
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1-2') == ['1', '2']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1-2-3') == ['1', '2', '3']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1 -2-3') == ['1', '2', '3']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1 - 2-3') == ['1', '2', '3']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1- 2-3') == ['1', '2', '3']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1') == ['1']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1-') == ['1', '']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1-2-') == ['1', '2', '']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1-2-3-') == ['1', '2', '3', '']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1,2-3') == ['1,2', '3']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1,2-3-') == ['1,2', '3', '']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('1,2, 3,') == ['1,2, 3,']
assert npbc_regex.HYPHEN_SPLIT_REGEX.split('') == ['']