diff options
Diffstat (limited to 'tests/basics/struct1_intbig.py')
-rw-r--r-- | tests/basics/struct1_intbig.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/basics/struct1_intbig.py b/tests/basics/struct1_intbig.py index 380293f36..24541c8a4 100644 --- a/tests/basics/struct1_intbig.py +++ b/tests/basics/struct1_intbig.py @@ -36,3 +36,11 @@ print(struct.unpack("<Q", b"\xff\xff\xff\xff\xff\xff\xff\xff")) # check small int overflow print(struct.unpack("<i", b'\xff\xff\xff\x7f')) print(struct.unpack("<q", b'\xff\xff\xff\xff\xff\xff\xff\x7f')) + +# test with negative big integers that are actually small in magnitude +bigzero = (1 << 70) - (1 << 70) +for endian in "<>": + for type_ in "bhiq": + fmt = endian + type_ + b = struct.pack(fmt, -2 + bigzero) + print(fmt, b, struct.unpack(fmt, b)) |