Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(90438)

Side by Side Diff: Lib/ctypes/test/test_bitfields.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/ctypes/test/test_as_parameter.py ('k') | Lib/ctypes/test/test_callbacks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from ctypes import * 1 from ctypes import *
2 from ctypes.test import need_symbol 2 from ctypes.test import need_symbol
3 import unittest 3 import unittest
4 import os 4 import os
5 5
6 import ctypes 6 import ctypes
7 import _ctypes_test 7 import _ctypes_test
8 8
9 class BITS(Structure): 9 class BITS(Structure):
10 _fields_ = [("A", c_int, 1), 10 _fields_ = [("A", c_int, 1),
11 ("B", c_int, 2), 11 ("B", c_int, 2),
12 ("C", c_int, 3), 12 ("C", c_int, 3),
13 ("D", c_int, 4), 13 ("D", c_int, 4),
14 ("E", c_int, 5), 14 ("E", c_int, 5),
15 ("F", c_int, 6), 15 ("F", c_int, 6),
16 ("G", c_int, 7), 16 ("G", c_int, 7),
17 ("H", c_int, 8), 17 ("H", c_int, 8),
18 ("I", c_int, 9), 18 ("I", c_int, 9),
19 19
20 ("M", c_short, 1), 20 ("M", c_short, 1),
21 ("N", c_short, 2), 21 ("N", c_short, 2),
22 ("O", c_short, 3), 22 ("O", c_short, 3),
23 ("P", c_short, 4), 23 ("P", c_short, 4),
24 ("Q", c_short, 5), 24 ("Q", c_short, 5),
25 ("R", c_short, 6), 25 ("R", c_short, 6),
26 ("S", c_short, 7)] 26 ("S", c_short, 7)]
27 27
28 func = CDLL(_ctypes_test.__file__).unpack_bitfields 28 func = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE'])).un pack_bitfields
29 func.argtypes = POINTER(BITS), c_char 29 func.argtypes = POINTER(BITS), c_char
30 30
31 ##for n in "ABCDEFGHIMNOPQRS": 31 ##for n in "ABCDEFGHIMNOPQRS":
32 ## print n, hex(getattr(BITS, n).size), getattr(BITS, n).offset 32 ## print n, hex(getattr(BITS, n).size), getattr(BITS, n).offset
33 33
34 class C_Test(unittest.TestCase): 34 class C_Test(unittest.TestCase):
35 35
36 def test_ints(self): 36 def test_ints(self):
37 for i in range(512): 37 for i in range(512):
38 for name in "ABCDEFGHI": 38 for name in "ABCDEFGHI":
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 ("c", c_uint32, 4)] 282 ("c", c_uint32, 4)]
283 b = bytearray(4) 283 b = bytearray(4)
284 x = Big.from_buffer(b) 284 x = Big.from_buffer(b)
285 x.a = 0xabcdef 285 x.a = 0xabcdef
286 x.b = 1 286 x.b = 1
287 x.c = 2 287 x.c = 2
288 self.assertEqual(b, b'\xab\xcd\xef\x12') 288 self.assertEqual(b, b'\xab\xcd\xef\x12')
289 289
290 if __name__ == "__main__": 290 if __name__ == "__main__":
291 unittest.main() 291 unittest.main()
OLDNEW
« no previous file with comments | « Lib/ctypes/test/test_as_parameter.py ('k') | Lib/ctypes/test/test_callbacks.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+