Skip to content

Commit 7c42a18

Browse files
committed
add test cases for int fn
1 parent b24444e commit 7c42a18

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

tests/snippets/ints.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
assert int("101", 2) == 5
9191
assert int("101", base=2) == 5
9292
assert int(1) == 1
93+
assert int(' 1') == 1
94+
assert int('1 ') == 1
95+
assert int(' 1 ') == 1
96+
assert int('10', base=0) == 10
9397

9498
assert int.from_bytes(b'\x00\x10', 'big') == 16
9599
assert int.from_bytes(b'\x00\x10', 'little') == 4096
@@ -103,6 +107,13 @@
103107
assert (2147483647).to_bytes(8, 'big', signed=False) == b'\x00\x00\x00\x00\x7f\xff\xff\xff'
104108
assert (-2147483648).to_bytes(8, 'little', signed=True) == b'\x00\x00\x00\x80\xff\xff\xff\xff'
105109

110+
with assertRaises(ValueError):
111+
# check base first
112+
int(' 1 ', base=1)
113+
114+
with assertRaises(ValueError):
115+
int(' 1 ', base=37)
116+
106117
with assertRaises(TypeError):
107118
int(base=2)
108119

0 commit comments

Comments
 (0)