Beispiel #1
0
 def test_cast(self):
     a = core.OctetBitString(b'\x00\x01\x02\x03')
     self.assertEqual(b'\x00\x01\x02\x03', a.native)
     b = a.cast(core.BitString)
     self.assertIsInstance(b, core.BitString)
     self.assertEqual((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
                       0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1), b.native)
     c = a.cast(core.IntegerBitString)
     self.assertIsInstance(c, core.IntegerBitString)
     self.assertEqual(66051, c.native)
Beispiel #2
0
 def compare_primitive_info():
     return (
         (core.ObjectIdentifier('1.2.3'), core.ObjectIdentifier('1.2.3'),
          True),
         (core.Integer(1), Enum(1), False),
         (core.Integer(1), core.Integer(1, tag_type='implicit',
                                        tag=5), True),
         (core.Integer(1), core.Integer(1, tag_type='explicit',
                                        tag=5), True),
         (core.Integer(1), core.Integer(2), False),
         (core.OctetString(b''), core.OctetString(b''), True),
         (core.OctetString(b''), core.OctetString(b'1'), False),
         (core.OctetString(b''), core.OctetBitString(b''), False),
         (core.ParsableOctetString(b'12'), core.OctetString(b'12'), True),
         (core.ParsableOctetBitString(b'12'), core.OctetBitString(b'12'),
          True),
         (core.UTF8String('12'), core.UTF8String('12'), True),
         (core.UTF8String('12'), core.UTF8String('1'), False),
         (core.UTF8String('12'), core.IA5String('12'), False),
     )