-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbooltest.py
More file actions
85 lines (67 loc) · 2.18 KB
/
booltest.py
File metadata and controls
85 lines (67 loc) · 2.18 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
#! env python3
# -*- coding: utf-8 -*-
def proc_before(src, dst):
if src == "any" and dst == "any":
print(" > src dst")
elif src != "any" and dst == "any":
print(" > src eq {0} dst".format(src))
elif src == "any" and dst != "any":
print(" > src dst eq {0}".format(dst))
elif src != "any" and dst != "any":
print(" > src eq {0} dst eq {1}".format(src, dst))
def proc_after(src, dst):
if (src == "any" and dst == "any") or (src == "" and dst == ""):
print(" > src dst")
elif (src != "any" and dst == "any") or (src != "" and dst == ""):
print(" > src eq {0} dst".format(src))
elif (src == "any" and dst != "any") or (src == "" and dst != ""):
print(" > src dst eq {0}".format(dst))
else:
print(" > src eq {0} dst eq {1}".format(src, dst))
def proc_after2(src, dst):
if (src == "any" or src == "") or (dst == "" or dst == "any"):
print(" > src dst")
elif (src != "any" and src != "" ) or (dst == "" or dst == "any"):
print(" > src eq {0} dst".format(src))
elif (src == "any" or src == "" ) or (dst != "any" and dst != ""):
print(" > src dst eq {0}".format(dst))
else:
print(" > src eq {0} dst eq {1}".format(src, dst))
def proc_after3(src, dst):
if src == "":
src = "any"
if dst == "":
dst = "any"
if src == "any" and dst == "any":
print(" > src dst")
elif src != "any" and dst == "any":
print(" > src eq {0} dst".format(src))
elif src == "any" and dst != "any":
print(" > src dst eq {0}".format(dst))
elif src != "any" and dst != "any":
print(" > src eq {0} dst eq {1}".format(src, dst))
def test(func):
print("any, any")
func("any", "any")
print("80, any")
func("80", "any")
print("any, 80")
func("any", "80")
print("80, 443")
func("80", "443")
print("(),()")
func("", "")
print("80, ()")
func("80", "")
print("(), 80")
func("", "80")
print("80, 443")
func("80", "443")
print("any, ()")
func("any", "")
print("(), any")
func("", "any")
print("=== before ===")
test(proc_before)
print("=== after ===")
test(proc_after3)