diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-07-29 14:36:03 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-07-29 14:36:03 +0200 |
commit | 245edd4d52ba44708652830bb6b51f607cfbb35e (patch) | |
tree | 7ef9e17066dfe26c791e37609e7aff03a3b55ce2 /Lib | |
parent | 34a0105bee3166cec8b5bcb48d303ba31473d742 (diff) | |
parent | 5ef6fde92c76df03455481bb1f4d6f2125c9e3ac (diff) | |
download | cpython-git-245edd4d52ba44708652830bb6b51f607cfbb35e.tar.gz |
Merge 3.5 (ctypes)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/test/test_bitfields.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py index 9ca053d201..b39d82cc0b 100644 --- a/Lib/ctypes/test/test_bitfields.py +++ b/Lib/ctypes/test/test_bitfields.py @@ -259,5 +259,33 @@ class BitFieldTest(unittest.TestCase): x.a = 0xFEDCBA9876543211 self.assertEqual(x.a, 0xFEDCBA9876543211) + @need_symbol('c_uint32') + def test_uint32_swap_little_endian(self): + # Issue #23319 + class Little(LittleEndianStructure): + _fields_ = [("a", c_uint32, 24), + ("b", c_uint32, 4), + ("c", c_uint32, 4)] + b = bytearray(4) + x = Little.from_buffer(b) + x.a = 0xabcdef + x.b = 1 + x.c = 2 + self.assertEqual(b, b'\xef\xcd\xab\x21') + + @need_symbol('c_uint32') + def test_uint32_swap_big_endian(self): + # Issue #23319 + class Big(BigEndianStructure): + _fields_ = [("a", c_uint32, 24), + ("b", c_uint32, 4), + ("c", c_uint32, 4)] + b = bytearray(4) + x = Big.from_buffer(b) + x.a = 0xabcdef + x.b = 1 + x.c = 2 + self.assertEqual(b, b'\xab\xcd\xef\x12') + if __name__ == "__main__": unittest.main() |