[pypy-commit] pypy py3.5: Extend struct half-float test with native formats.

mjacob pypy.commits at gmail.com
Mon Mar 19 12:07:35 EDT 2018


Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.5
Changeset: r94006:e4575f135d6f
Date: 2018-03-19 17:02 +0100
http://bitbucket.org/pypy/pypy/changeset/e4575f135d6f/

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