summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_capi/test_long.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_capi/test_long.py')
-rw-r--r--Lib/test/test_capi/test_long.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_capi/test_long.py b/Lib/test/test_capi/test_long.py
index bdbdd7b..48e795f 100644
--- a/Lib/test/test_capi/test_long.py
+++ b/Lib/test/test_capi/test_long.py
@@ -631,6 +631,31 @@ class LongTests(unittest.TestCase):
# CRASHES getsign(NULL)
+ def test_long_asint32(self):
+ # Test PyLong_AsInt32() and PyLong_FromInt32()
+ to_int32 = _testlimitedcapi.pylong_asint32
+ from _testcapi import INT32_MIN, INT32_MAX
+ self.check_long_asint(to_int32, INT32_MIN, INT32_MAX)
+
+ def test_long_asint64(self):
+ # Test PyLong_AsInt64() and PyLong_FromInt64()
+ as_int64 = _testlimitedcapi.pylong_asint64
+ from _testcapi import INT64_MIN, INT64_MAX
+ self.check_long_asint(as_int64, INT64_MIN, INT64_MAX)
+
+ def test_long_asuint32(self):
+ # Test PyLong_AsUInt32() and PyLong_FromUInt32()
+ as_uint32 = _testlimitedcapi.pylong_asuint32
+ from _testcapi import UINT32_MAX
+ self.check_long_asint(as_uint32, 0, UINT32_MAX,
+ negative_value_error=ValueError)
+
+ def test_long_asuint64(self):
+ # Test PyLong_AsUInt64() and PyLong_FromUInt64()
+ as_uint64 = _testlimitedcapi.pylong_asuint64
+ from _testcapi import UINT64_MAX
+ self.check_long_asint(as_uint64, 0, UINT64_MAX,
+ negative_value_error=ValueError)
if __name__ == "__main__":
unittest.main()