-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_numpad.py
120 lines (101 loc) · 4.01 KB
/
test_numpad.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
# coding=UTF-8
from decimal import Decimal
from kle2xy import KLE2xy
numpad_code = """["Numlock","/","*","-"],
["7\\nHome","8\\nUp","9\\nPgUp",{h:2},"+"],
["4\\nLeft","5","6\\nRight"],
["1\\nEnd","2\\nDown","3\\nPgDn",{h:2},"Enter"],
[{w:2},"0\\nIns",".\\nDel"]
"""
def test_numpad():
i = KLE2xy(numpad_code)
# First row
assert i[0][0]['name'] == 'Numlock'
assert i[0][0]['width'] == Decimal('1')
assert i[0][0]['height'] == Decimal('1')
assert i[0][0]['x'] == Decimal('9.525')
assert i[0][0]['y'] == Decimal('-9.525')
assert i[0][1]['name'] == '/'
assert i[0][1]['width'] == Decimal('1')
assert i[0][1]['height'] == Decimal('1')
assert i[0][1]['x'] == Decimal('28.575')
assert i[0][1]['y'] == Decimal('-9.525')
assert i[0][2]['name'] == '*'
assert i[0][2]['width'] == Decimal('1')
assert i[0][2]['height'] == Decimal('1')
assert i[0][2]['x'] == Decimal('47.625')
assert i[0][2]['y'] == Decimal('-9.525')
assert i[0][3]['name'] == '-'
assert i[0][3]['width'] == Decimal('1')
assert i[0][3]['height'] == Decimal('1')
assert i[0][3]['x'] == Decimal('66.675')
assert i[0][3]['y'] == Decimal('-9.525')
# Second row
assert i[1][0]['name'] == '7\nHome'
assert i[1][0]['width'] == Decimal('1')
assert i[1][0]['height'] == Decimal('1')
assert i[1][0]['x'] == Decimal('9.525')
assert i[1][0]['y'] == Decimal('-28.575')
assert i[1][1]['name'] == '8\nUp'
assert i[1][1]['width'] == Decimal('1')
assert i[1][1]['height'] == Decimal('1')
assert i[1][1]['x'] == Decimal('28.575')
assert i[1][1]['y'] == Decimal('-28.575')
assert i[1][2]['name'] == '9\nPgUp'
assert i[1][2]['width'] == Decimal('1')
assert i[1][2]['height'] == Decimal('1')
assert i[1][2]['x'] == Decimal('47.625')
assert i[1][2]['y'] == Decimal('-28.575')
assert i[1][3]['name'] == '+'
assert i[1][3]['width'] == Decimal('1')
assert i[1][3]['height'] == Decimal('2')
assert i[1][3]['x'] == Decimal('66.675')
assert i[1][3]['y'] == Decimal('-38.1')
# Third row
assert i[2][0]['name'] == '4\nLeft'
assert i[2][0]['width'] == Decimal('1')
assert i[2][0]['height'] == Decimal('1')
assert i[2][0]['x'] == Decimal('9.525')
assert i[2][0]['y'] == Decimal('-47.625')
assert i[2][1]['name'] == '5'
assert i[2][1]['width'] == Decimal('1')
assert i[2][1]['height'] == Decimal('1')
assert i[2][1]['x'] == Decimal('28.575')
assert i[2][1]['y'] == Decimal('-47.625')
assert i[2][2]['name'] == '6\nRight'
assert i[2][2]['width'] == Decimal('1')
assert i[2][2]['height'] == Decimal('1')
assert i[2][2]['x'] == Decimal('47.625')
assert i[2][2]['y'] == Decimal('-47.625')
# Fourth row
assert i[3][0]['name'] == '1\nEnd'
assert i[3][0]['width'] == Decimal('1')
assert i[3][0]['height'] == Decimal('1')
assert i[3][0]['x'] == Decimal('9.525')
assert i[3][0]['y'] == Decimal('-66.675')
assert i[3][1]['name'] == '2\nDown'
assert i[3][1]['width'] == Decimal('1')
assert i[3][1]['height'] == Decimal('1')
assert i[3][1]['x'] == Decimal('28.575')
assert i[3][1]['y'] == Decimal('-66.675')
assert i[3][2]['name'] == '3\nPgDn'
assert i[3][2]['width'] == Decimal('1')
assert i[3][2]['height'] == Decimal('1')
assert i[3][2]['x'] == Decimal('47.625')
assert i[3][2]['y'] == Decimal('-66.675')
assert i[3][3]['name'] == 'Enter'
assert i[3][3]['width'] == Decimal('1')
assert i[3][3]['height'] == Decimal('2')
assert i[3][3]['x'] == Decimal('66.675')
assert i[3][3]['y'] == Decimal('-76.2')
# Fifth row
assert i[4][0]['name'] == '0\nIns'
assert i[4][0]['width'] == Decimal('2')
assert i[4][0]['height'] == Decimal('1')
assert i[4][0]['x'] == Decimal('19.05')
assert i[4][0]['y'] == Decimal('-85.725')
assert i[4][1]['name'] == '.\nDel'
assert i[4][1]['width'] == Decimal('1')
assert i[4][1]['height'] == Decimal('1')
assert i[4][1]['x'] == Decimal('47.625')
assert i[4][1]['y'] == Decimal('-85.725')