add more cases

This commit is contained in:
blueloveTH 2024-02-05 15:54:39 +08:00
parent faa01ac82e
commit c154d40da6

View File

@ -205,3 +205,21 @@ assert repr(c.void_p(255)) == '<void* at 0xff>'
assert repr(c.void_p(256)) == '<void* at 0x100>'
assert repr(c.void_p(257)) == '<void* at 0x101>'
assert repr(c.void_p(17)) == '<void* at 0x11>'
# random hex test
import random
def test(__min, __max):
for _ in range(100):
num = random.randint(__min, __max)
hex_num = hex(num)
assert eval(hex_num) == num
if num >= 0:
assert repr(c.void_p(num)) == f'<void* at 0x{hex_num[2:]}>'
test(0, 100)
test(0, 100000)
test(-100, 100)
test(-100000, 100000)
test(-2**60, 2**60)