1 from test
.test_support
import TestFailed
5 # XXX Much more needed here.
7 # Test the full range of Python ints.
10 for expected
in (-n
, n
):
11 s
= marshal
.dumps(expected
)
12 got
= marshal
.loads(s
)
14 raise TestFailed("for int %d, marshal string is %r, loaded "
15 "back as %d" % (expected
, s
, got
))
18 # Simulate int marshaling on a 64-bit box. This is most interesting if
19 # we're running the test on a 32-bit box, of course.
21 def to_little_endian_string(value
, nbytes
):
23 for i
in range(nbytes
):
24 bytes
.append(chr(value
& 0xff))
28 maxint64
= (1L << 63) - 1
29 minint64
= -maxint64
-1
31 for base
in maxint64
, minint64
, -maxint64
, -(minint64
>> 1):
33 s
= 'I' + to_little_endian_string(base
, 8)
34 got
= marshal
.loads(s
)
36 raise TestFailed("for int %d, simulated marshal string is %r, "
37 "loaded back as %d" % (base
, s
, got
))
38 if base
== -1: # a fixed-point for shifting right 1
43 # Simple-minded check for SF 588452: Debug build crashes
44 marshal
.dumps([128] * 1000)