فهرست منبع

add more cases

blueloveTH 2 سال پیش
والد
کامیت
c154d40da6
1فایلهای تغییر یافته به همراه18 افزوده شده و 0 حذف شده
  1. 18 0
      tests/04_str.py

+ 18 - 0
tests/04_str.py

@@ -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)