-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
52 lines (46 loc) · 1.12 KB
/
test.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
from regex import RegEx
# run each test case
def test(num, exp, txt):
re = RegEx(exp)
print("Pattern: ", exp)
print("String: ", txt)
print(f"Test {num} result: ", re.match(txt), end='\n\n')
if __name__ == '__main__':
# test cases
tests = [
{
'pattern': 'John',
'string': 'Hello John how are you John?',
},
{
'pattern': '[a-zA-Z0-9]',
'string': 'Hello77',
},
{
'pattern': '[0-9]',
'string': 'Hello77',
},
{
'pattern': '[a-z]',
'string': 'simple',
},
{
'pattern': '[a-z0-9]@[a-z].(com|net|org)',
'string': '[email protected]',
},
{
'pattern': '[A-Z]',
'string': 'Hello',
},
]
tests_1 = [
{
'pattern': '[a-z0-9]@[a-z].(com|net|org)',
'string': '[email protected]',
},
]
# run all test cases
for i in range(len(tests)):
case = tests[i]
# run test case
test(i + 1, case['pattern'], case['string'])