-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
60 lines (52 loc) · 1.77 KB
/
test.py
File metadata and controls
60 lines (52 loc) · 1.77 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
import converter
f = {
'digit': 1234,
'sign': '+'
}
num = ['+24', 2, '+1']
assert(
[converter.convert(n, f, {'sign': '/'}) for n in num]
== ['/7', '1', '/0']
), 'Conversion was wrong'
converter.modifyF(5)
converter.customT(2468)
num = [24, 2, 10]
assert(
[converter.convert(n) for n in num] == ['86', '6', '44']
), 'Conversion was wrong'
converter.modifyDef(5, 2)
num = [41, '024', 00]
assert(
[converter.convert(n) for n in num] == ['10101', '1110', '0']
), 'Conversion was wrong'
converter.customDef('ABCD', '*', '-', 'DCBA', '+', '-')
num = ['DC', '*AD', '*DB', 'BAD']
assert(
[converter.convert(n) for n in num] == ['AB', '+A', '+AC', 'CDA']
), 'Conversion was wrong'
converter.customF('😁😃', sep = '➗')
converter.modifyT(4)
num = ['-😁😃➗😁😃😃', '😁😃➗😃😁😃', '-😁😃😃😁']
assert(
[converter.convert(n) for n in num] == ['-1.12', '1.22', '-12']
), 'Conversion was wrong'
converter.modifyF(4)
t = {
'digit': '😁😃',
'sign': '-',
'sep': '➗'
}
num = [-1.3, -1.2, 2.13, .333]
assert(
[converter.convert(n, to = t) for n in num]
== ['-😃➗😃😃', '-😃➗😃', '😃😁➗😁😃😃😃', '😁➗😃😃😃😃😃😃']
), 'Conversion was wrong'
converter.setPrec(3)
assert(
[converter.convert(n, to = t) for n in num]
== ['-😃➗😃😃', '-😃➗😃', '😃😁➗😁😃😃', '😁➗😃😃😃']
), 'Conversion was wrong'
assert(
[converter.convert(n, to = t, pre = 6) for n in num]
== ['-😃➗😃😃', '-😃➗😃', '😃😁➗😁😃😃😃', '😁➗😃😃😃😃😃😃']
), 'Conversion was wrong'