From 8664a6574b4cb448df26bfaa0e12eb203cc5d759 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 12 May 2019 11:17:29 -0400 Subject: use approx of original @godlygeek code for smallints; add tests --- tests/basics/bigint_array_overflow.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/basics/bigint_array_overflow.py (limited to 'tests/basics/bigint_array_overflow.py') diff --git a/tests/basics/bigint_array_overflow.py b/tests/basics/bigint_array_overflow.py new file mode 100644 index 000000000..0dd79c23d --- /dev/null +++ b/tests/basics/bigint_array_overflow.py @@ -0,0 +1,28 @@ +import skip_if +skip_if.no_bigint() + +try: + from array import array +except ImportError: + print("SKIP") + raise SystemExit + +def test_array_overflow(typecode, val): + try: + print(array(typecode, [val])) + except OverflowError: + print('OverflowError') + +# big int -1 +test_array_overflow('Q', -2**64 // 2**64) +test_array_overflow('L', -2**64 // 2**64) +test_array_overflow('I', -2**64 // 2**64) +test_array_overflow('H', -2**64 // 2**64) +test_array_overflow('B', -2**64 // 2**64) + +# big int 2**63 +test_array_overflow('q', 2**63) +test_array_overflow('l', 2**63) +test_array_overflow('i', 2**63) +test_array_overflow('h', 2**63) +test_array_overflow('b', 2**63) -- cgit v1.2.3