From c154d40da6661dab495730a551b404c2478a71dc Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 5 Feb 2024 15:54:39 +0800 Subject: [PATCH] add more cases --- tests/04_str.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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)