# Path: ldaptor/protocols/pureber.py
# CLASS_MASK              = 0xc0
# CLASS_UNIVERSAL = 0x00
# CLASS_APPLICATION       = 0x40
# CLASS_CONTEXT           = 0x80
# CLASS_PRIVATE           = 0xc0
# STRUCTURED_MASK         = 0x20
# STRUCTURED              = 0x20
# NOT_STRUCTURED          = 0x00
# TAG_MASK                = 0x1f
# class UnknownBERTag(Exception):
# class BERBase:
# class BERStructured(BERBase):
# class BERException(Exception): pass
# class BERExceptionInsufficientData(Exception): pass
# class BERInteger(BERBase):
# class BEROctetString(BERBase):
# class BERNull(BERBase):
# class BERBoolean(BERBase):
# class BEREnumerated(BERInteger):
# class BERSequence(BERStructured, UserList.UserList):
# class BERSequenceOf(BERSequence):
# class BERSet(BERSequence):
# class BERDecoderContext:
#     def __init__(self, tag, context):
#     def __str__(self):
# def berDecodeLength(m, offset=0):
# def int2berlen(i):
# def int2ber(i, signed=True):
# def ber2int(e, signed=True):
#     def identification(self):
#     def __init__(self, tag=None):
#     def __len__(self):
#     def __cmp__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def identification(self):
# def need(buf, n):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, value=None, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, value=None, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, value=None, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, value=None, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def __init__(self, fallback=None, inherit=None):
#     def lookup_id(self, id):
#     def inherit(self):
#     def __repr__(self):
# def berDecodeObject(context, m):
# def berDecodeMultiple(content, berdecoder):


from twisted.trial import unittest
from ldaptor.protocols import pureber
import types
        (128, [0x01, 0x01, 0xFF], 0xFF),
        (255, [0x01, 0x01, 0xFF], 0xFF),
        (256, [0x01, 0x01, 0xFF], 0xFF),
        (9999, [0x01, 0x01, 0xFF], 0xFF),
        )

    def testToBERBooleanKnownValues(self):
        """str(BERBoolean(n)) should give known result with known input"""
        for integer, encoded, dummy in self.knownValues:
            result = pureber.BERBoolean(integer)
            result = str(result)
            result = map(ord, result)
            assert encoded==result

    def testFromBERBooleanKnownValues(self):
        """BERBoolean(encoded="...") should give known result with known input"""
        for integer, encoded, canon in self.knownValues:
            m=s(*encoded)
            result, bytes = pureber.berDecodeObject(pureber.BERDecoderContext(), m)
            self.assertEquals(bytes, len(m))
            assert isinstance(result, pureber.BERBoolean)
            result = result.value
            assert result==canon

    def testPartialBERBooleanEncodings(self):
        """BERBoolean(encoded="...") with too short input should throw BERExceptionInsufficientData"""
        m=str(pureber.BERBoolean(42))
        assert len(m)==3
        self.assertRaises(pureber.BERExceptionInsufficientData, pureber.berDecodeObject, pureber.BERDecoderContext(), m[:2])
        self.assertRaises(pureber.BERExceptionInsufficientData, pureber.berDecodeObject, pureber.BERDecoderContext(), m[:1])

# Path: ldaptor/protocols/pureber.py
# CLASS_MASK              = 0xc0
# CLASS_UNIVERSAL = 0x00
# CLASS_APPLICATION       = 0x40
# CLASS_CONTEXT           = 0x80
# CLASS_PRIVATE           = 0xc0
# STRUCTURED_MASK         = 0x20
# STRUCTURED              = 0x20
# NOT_STRUCTURED          = 0x00
# TAG_MASK                = 0x1f
# class UnknownBERTag(Exception):
# class BERBase:
# class BERStructured(BERBase):
# class BERException(Exception): pass
# class BERExceptionInsufficientData(Exception): pass
# class BERInteger(BERBase):
# class BEROctetString(BERBase):
# class BERNull(BERBase):
# class BERBoolean(BERBase):
# class BEREnumerated(BERInteger):
# class BERSequence(BERStructured, UserList.UserList):
# class BERSequenceOf(BERSequence):
# class BERSet(BERSequence):
# class BERDecoderContext:
#     def __init__(self, tag, context):
#     def __str__(self):
# def berDecodeLength(m, offset=0):
# def int2berlen(i):
# def int2ber(i, signed=True):
# def ber2int(e, signed=True):
#     def identification(self):
#     def __init__(self, tag=None):
#     def __len__(self):
#     def __cmp__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def identification(self):
# def need(buf, n):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, value=None, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, value=None, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, value=None, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def fromBER(klass, tag, content, berdecoder=None):
#     def __init__(self, value=None, tag=None):
#     def __str__(self):
#     def __repr__(self):
#     def __init__(self, fallback=None, inherit=None):
#     def lookup_id(self, id):
#     def inherit(self):
#     def __repr__(self):
# def berDecodeObject(context, m):
# def berDecodeMultiple(content, berdecoder):


# Path: ldaptor/test/test_pureber.py
from twisted.trial import unittest
from ldaptor.protocols import pureber
import types

        (128, [0x01, 0x01, 0xFF], 0xFF),
        (255, [0x01, 0x01, 0xFF], 0xFF),
        (256, [0x01, 0x01, 0xFF], 0xFF),
        (9999, [0x01, 0x01, 0xFF], 0xFF),
        )

    def testToBERBooleanKnownValues(self):
        """str(BERBoolean(n)) should give known result with known input"""
        for integer, encoded, dummy in self.knownValues:
            result = pureber.BERBoolean(integer)
            result = str(result)
            result = map(ord, result)
            assert encoded==result

    def testFromBERBooleanKnownValues(self):
        """BERBoolean(encoded="...") should give known result with known input"""
        for integer, encoded, canon in self.knownValues:
            m=s(*encoded)
            result, bytes = pureber.berDecodeObject(pureber.BERDecoderContext(), m)
            self.assertEquals(bytes, len(m))
            assert isinstance(result, pureber.BERBoolean)
            result = result.value
            assert result==canon

    def testPartialBERBooleanEncodings(self):
        """BERBoolean(encoded="...") with too short input should throw BERExceptionInsufficientData"""
        m=str(pureber.BERBoolean(42))
        assert len(m)==3
        self.assertRaises(pureber.BERExceptionInsufficientData, pureber.berDecodeObject, pureber.BERDecoderContext(), m[:2])
        self.assertRaises(pureber.BERExceptionInsufficientData, pureber.berDecodeObject, pureber.BERDecoderContext(), m[:1])

        self.assertEquals((None, 0), pureber.berDecodeObject(pureber.BERDecoderContext(), ''))