# Path: asn1crypto/parser.py
# _PY2 = sys.version_info <= (3,)
# _INSUFFICIENT_DATA_MESSAGE = 'Insufficient data - %s bytes requested but only %s available'
# _MAX_DEPTH = 10
# def emit(class_, method, tag, contents):
# def parse(contents, strict=False):
# def peek(contents):
# def _parse(encoded_data, data_len, pointer=0, lengths_only=False, depth=0):
# def _dump_header(class_, method, tag, contents):


import unittest
from asn1crypto import parser
from ._unittest_compat import patch
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function




patch()


class ParserTests(unittest.TestCase):

    def test_parser(self):
        result = parser.parse(b'\x02\x01\x00')
        self.assertIsInstance(result, tuple)
        self.assertEqual(0, result[0])
        self.assertEqual(0, result[1])
        self.assertEqual(2, result[2])
        self.assertEqual(b'\x02\x01', result[3])
        self.assertEqual(b'\x00', result[4])
        self.assertEqual(b'', result[5])

    def test_peek(self):
        self.assertEqual(3, parser.peek(b'\x02\x01\x00\x00'))

    def test_parse_indef_nested(self):
        data = b'\x24\x80\x24\x80\x24\x80\x04\x00\x00\x00\x00\x00\x00\x00'

# Path: asn1crypto/parser.py
# _PY2 = sys.version_info <= (3,)
# _INSUFFICIENT_DATA_MESSAGE = 'Insufficient data - %s bytes requested but only %s available'
# _MAX_DEPTH = 10
# def emit(class_, method, tag, contents):
# def parse(contents, strict=False):
# def peek(contents):
# def _parse(encoded_data, data_len, pointer=0, lengths_only=False, depth=0):
# def _dump_header(class_, method, tag, contents):


# Path: tests/test_parser.py
import unittest
from asn1crypto import parser
from ._unittest_compat import patch

# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function




patch()


class ParserTests(unittest.TestCase):

    def test_parser(self):
        result = parser.parse(b'\x02\x01\x00')
        self.assertIsInstance(result, tuple)
        self.assertEqual(0, result[0])
        self.assertEqual(0, result[1])
        self.assertEqual(2, result[2])
        self.assertEqual(b'\x02\x01', result[3])
        self.assertEqual(b'\x00', result[4])
        self.assertEqual(b'', result[5])

    def test_peek(self):
        self.assertEqual(3, parser.peek(b'\x02\x01\x00\x00'))

    def test_parse_indef_nested(self):
        data = b'\x24\x80\x24\x80\x24\x80\x04\x00\x00\x00\x00\x00\x00\x00'

        result = parser.parse(data)