diff --git a/tests/04_str.py b/tests/04_str.py index 79cc89cb..a1e9c8ce 100644 --- a/tests/04_str.py +++ b/tests/04_str.py @@ -205,3 +205,21 @@ assert repr(c.void_p(255)) == '' assert repr(c.void_p(256)) == '' assert repr(c.void_p(257)) == '' assert repr(c.void_p(17)) == '' + +# 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'' + +test(0, 100) +test(0, 100000) +test(-100, 100) +test(-100000, 100000) +test(-2**60, 2**60)