def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, length, state, decodeFun, substrateFun): head, tail = substrate[:length], substrate[length:] if not head: return self._createComponent(asn1Spec, tagSet, 0), tail value = from_bytes(head, signed=True) return self._createComponent(asn1Spec, tagSet, value), tail
def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, length, state, decodeFun, substrateFun): if tagSet[0].tagFormat != tag.tagFormatSimple: raise error.PyAsn1Error('Simple tag format expected') head, tail = substrate[:length], substrate[length:] if not head: return self._createComponent(asn1Spec, tagSet, 0), tail value = from_bytes(head, signed=True) return self._createComponent(asn1Spec, tagSet, value), tail
def valueDecoder(self, substrate, asn1Spec, tagSet=None, length=None, state=None, decodeFun=None, substrateFun=None, **options): if tagSet[0].tagFormat != tag.tagFormatSimple: raise error.PyAsn1Error('Simple tag format expected') head, tail = substrate[:length], substrate[length:] if not head: return self._createComponent(asn1Spec, tagSet, 0), tail value = from_bytes(head, signed=True) return self._createComponent(asn1Spec, tagSet, value), tail
def test_from_bytes_empty(self): assert 0 == integer.from_bytes('')
def test_from_bytes_signed(self): assert 66051 == integer.from_bytes('\x01\x02\x03', signed=False)
def test_from_bytes_unsigned(self): assert -66051 == integer.from_bytes('\xfe\xfd\xfd', signed=True)
def test_from_bytes_zero(self): assert 0 == integer.from_bytes('\x00', signed=False)
def test_from_bytes_signed(self): assert 66051 == integer.from_bytes(bytes([0, 1, 2, 3]), signed=False)
def test_from_bytes_unsigned(self): assert -66051 == integer.from_bytes(bytes([254, 253, 253]), signed=True)
def test_from_bytes_zero(self): assert 0 == integer.from_bytes(bytes([0]), signed=False)