# Path: ulid/base32.py
# ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
# DECODING = array.array(
#     'B',
#     (0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01,
#      0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
#      0x0F, 0x10, 0x11, 0x01, 0x12, 0x13, 0x01, 0x14, 0x15, 0x00,
#      0x16, 0x17, 0x18, 0x19, 0x1A, 0xFF, 0x1B, 0x1C, 0x1D, 0x1E,
#      0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C,
#      0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x01, 0x12, 0x13, 0x01, 0x14,
#      0x15, 0x00, 0x16, 0x17, 0x18, 0x19, 0x1A, 0xFF, 0x1B, 0x1C,
#      0x1D, 0x1E, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF)
# )
# def encode(value: hints.Buffer) -> str:
# def encode_ulid(value: hints.Buffer) -> str:
# def encode_timestamp(timestamp: hints.Buffer) -> str:
# def encode_randomness(randomness: hints.Buffer) -> str:
# def decode(value: str) -> bytes:
# def decode_ulid(value: str) -> bytes:
# def decode_timestamp(timestamp: str) -> bytes:
# def decode_randomness(randomness: str) -> bytes:
# def str_to_bytes(value: str, expected_length: int) -> bytes:


import pytest
from ulid import base32
"""
    test_base32
    ~~~~~~~~~~~

    Tests for the :mod:`~ulid.base32` module.
"""


NON_BASE_32_EXC_REGEX = r'^Non-base32 character found'
NON_ASCII_EXC_REGEX = r'Expects value that can be encoded in ASCII charset'
ENCODE_BYTE_SIZE_EXC_REGEX = r'^Expects bytes in sizes of'
ENCODE_ULID_BYTE_SIZE_EXC_REGEX = r'Expects 16 bytes for'
ENCODE_TIMESTAMP_BYTE_SIZE_EXC_REGEX = r'Expects 6 bytes for'
ENCODE_RANDOMNESS_BYTE_SIZE_EXC_REGEX = r'Expects 10 bytes for'
DECODE_STR_LEN_EXC_REGEX = r'^Expects string in lengths of'
DECODE_ULID_STR_LEN_EXC_REGEX = r'^Expects 26 characters for decoding'
DECODE_TIMESTAMP_STR_LEN_EXC_REGEX = r'^Expects 10 characters for decoding'
DECODE_RANDOMNESS_STR_LEN_EXC_REGEX = r'^Expects 16 characters for decoding'
TIMESTAMP_OVERFLOW_EXC_REGEX = r'Timestamp value too large and will overflow 128-bits. Must be between b"0" and b"7"'


@pytest.fixture(scope='session')
def decoding_alphabet():
    """
    Fixture that yields the entire alphabet that is valid for base32 decoding.
    """

# Path: ulid/base32.py
# ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
# DECODING = array.array(
#     'B',
#     (0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01,
#      0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
#      0x0F, 0x10, 0x11, 0x01, 0x12, 0x13, 0x01, 0x14, 0x15, 0x00,
#      0x16, 0x17, 0x18, 0x19, 0x1A, 0xFF, 0x1B, 0x1C, 0x1D, 0x1E,
#      0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x0B, 0x0C,
#      0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x01, 0x12, 0x13, 0x01, 0x14,
#      0x15, 0x00, 0x16, 0x17, 0x18, 0x19, 0x1A, 0xFF, 0x1B, 0x1C,
#      0x1D, 0x1E, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
#      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF)
# )
# def encode(value: hints.Buffer) -> str:
# def encode_ulid(value: hints.Buffer) -> str:
# def encode_timestamp(timestamp: hints.Buffer) -> str:
# def encode_randomness(randomness: hints.Buffer) -> str:
# def decode(value: str) -> bytes:
# def decode_ulid(value: str) -> bytes:
# def decode_timestamp(timestamp: str) -> bytes:
# def decode_randomness(randomness: str) -> bytes:
# def str_to_bytes(value: str, expected_length: int) -> bytes:


# Path: tests/test_base32.py
import pytest
from ulid import base32

"""
    test_base32
    ~~~~~~~~~~~

    Tests for the :mod:`~ulid.base32` module.
"""


NON_BASE_32_EXC_REGEX = r'^Non-base32 character found'
NON_ASCII_EXC_REGEX = r'Expects value that can be encoded in ASCII charset'
ENCODE_BYTE_SIZE_EXC_REGEX = r'^Expects bytes in sizes of'
ENCODE_ULID_BYTE_SIZE_EXC_REGEX = r'Expects 16 bytes for'
ENCODE_TIMESTAMP_BYTE_SIZE_EXC_REGEX = r'Expects 6 bytes for'
ENCODE_RANDOMNESS_BYTE_SIZE_EXC_REGEX = r'Expects 10 bytes for'
DECODE_STR_LEN_EXC_REGEX = r'^Expects string in lengths of'
DECODE_ULID_STR_LEN_EXC_REGEX = r'^Expects 26 characters for decoding'
DECODE_TIMESTAMP_STR_LEN_EXC_REGEX = r'^Expects 10 characters for decoding'
DECODE_RANDOMNESS_STR_LEN_EXC_REGEX = r'^Expects 16 characters for decoding'
TIMESTAMP_OVERFLOW_EXC_REGEX = r'Timestamp value too large and will overflow 128-bits. Must be between b"0" and b"7"'


@pytest.fixture(scope='session')
def decoding_alphabet():
    """
    Fixture that yields the entire alphabet that is valid for base32 decoding.
    """

    return base32.ENCODING + 'lLiIoO'