Kaydet (Commit) c5c9ce95 authored tarafından Tim Peters's avatar Tim Peters

Add missing SVN eol-style property to text files.

üst 715a4cde
import sys, unittest import sys, unittest
from ctypes import * from ctypes import *
structures = [] structures = []
byteswapped_structures = [] byteswapped_structures = []
if sys.byteorder == "little": if sys.byteorder == "little":
SwappedStructure = BigEndianStructure SwappedStructure = BigEndianStructure
else: else:
SwappedStructure = LittleEndianStructure SwappedStructure = LittleEndianStructure
for typ in [c_short, c_int, c_long, c_longlong, for typ in [c_short, c_int, c_long, c_longlong,
c_float, c_double, c_float, c_double,
c_ushort, c_uint, c_ulong, c_ulonglong]: c_ushort, c_uint, c_ulong, c_ulonglong]:
class X(Structure): class X(Structure):
_pack_ = 1 _pack_ = 1
_fields_ = [("pad", c_byte), _fields_ = [("pad", c_byte),
("value", typ)] ("value", typ)]
class Y(SwappedStructure): class Y(SwappedStructure):
_pack_ = 1 _pack_ = 1
_fields_ = [("pad", c_byte), _fields_ = [("pad", c_byte),
("value", typ)] ("value", typ)]
structures.append(X) structures.append(X)
byteswapped_structures.append(Y) byteswapped_structures.append(Y)
class TestStructures(unittest.TestCase): class TestStructures(unittest.TestCase):
def test_native(self): def test_native(self):
for typ in structures: for typ in structures:
## print typ.value ## print typ.value
self.failUnlessEqual(typ.value.offset, 1) self.failUnlessEqual(typ.value.offset, 1)
o = typ() o = typ()
o.value = 4 o.value = 4
self.failUnlessEqual(o.value, 4) self.failUnlessEqual(o.value, 4)
def test_swapped(self): def test_swapped(self):
for typ in byteswapped_structures: for typ in byteswapped_structures:
## print >> sys.stderr, typ.value ## print >> sys.stderr, typ.value
self.failUnlessEqual(typ.value.offset, 1) self.failUnlessEqual(typ.value.offset, 1)
o = typ() o = typ()
o.value = 4 o.value = 4
self.failUnlessEqual(o.value, 4) self.failUnlessEqual(o.value, 4)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment