Esempio n. 1
0
 def test_fail_on_dynamic_length(self):
     union = UnionTemplate('NotLegal', 'dymagic', parent=None)
     union.add(UInt(2, 'bar', None))
     struct = StructTemplate('Foo', 'foo', parent=None)
     struct.add(UInt(1, 'len', 22))
     struct.add(Char('len', 'dymagic', 'foo'))
     self.assertRaises(Exception, union.add, struct)
Esempio n. 2
0
 def test_fail_on_dynamic_length(self):
     union = UnionTemplate('NotLegal', 'dymagic', parent=None)
     union.add(UInt(2, 'bar', None))
     struct = StructTemplate('Foo', 'foo', parent=None)
     struct.add(UInt(1, 'len', 22))
     struct.add(Char('len', 'dymagic', 'foo'))
     self.assertRaises(Exception, union.add, struct)
Esempio n. 3
0
 def _check_length(self, length, *fields):
     union = UnionTemplate('Foo', 'foo', parent=None)
     for value in fields:
         union.add(value)
     self.assertEquals(union.get_static_length(), length)
Esempio n. 4
0
 def _get_foo_union(self):
     union = UnionTemplate('Foo', 'foo', parent=None)
     union.add(UInt(1, 'small', '0xff'))
     union.add(UInt(2, 'medium', '0xf00d'))
     union.add(UInt(4, 'large', None))
     return union
Esempio n. 5
0
 def _get_foo_union(self):
     union = UnionTemplate('Foo', 'foo', parent=None)
     union.add(UInt(1, 'small', '0xff'))
     union.add(UInt(2, 'medium', '0xf00d'))
     union.add(UInt(4, 'large', None))
     return union
Esempio n. 6
0
 def _check_length(self, length, *fields):
     union = UnionTemplate('Foo', 'foo', parent=None)
     for value in fields:
         union.add(value)
     self.assertEquals(union.get_static_length(), length)