[pypy-commit] pypy py3.6: Extend struct half-float test with native formats.
mjacob
pypy.commits at gmail.com
Mon Mar 19 12:19:39 EDT 2018
Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.6
Changeset: r94008:760c10a5b6d8
Date: 2018-03-19 17:14 +0100
http://bitbucket.org/pypy/pypy/changeset/760c10a5b6d8/
Log: Extend struct half-float test with native formats.
diff --git a/pypy/module/struct/test/test_struct.py b/pypy/module/struct/test/test_struct.py
--- a/pypy/module/struct/test/test_struct.py
+++ b/pypy/module/struct/test/test_struct.py
@@ -258,12 +258,19 @@
raises(OverflowError, pack, "<f", 10e100)
def test_half_floats(self):
+ import sys
pack = self.struct.pack
unpack = self.struct.unpack
assert pack("<e", 65504.0) == b'\xff\x7b'
assert pack(">e", 65504.0) == b'\x7b\xff'
assert unpack(">e", b'\x7b\xff') == (65504.0,)
raises(OverflowError, pack, "<e", 1e6)
+ if sys.byteorder == 'little':
+ assert pack("e", 65504.0) == b'\xff\x7b'
+ assert unpack("e", b'\xff\x7b') == (65504.0,)
+ else:
+ assert pack("e", 65504.0) == b'\x7b\xff'
+ assert unpack("e", b'\x7b\xff') == (65504.0,)
def test_bool(self):
pack = self.struct.pack
More information about the pypy-commit
mailing list