# Path: numcodecs/tests/common.py
# def compare_arrays(arr, res, precision=None):
# def check_encode_decode(arr, codec, precision=None):
# def check_encode_decode_partial(arr, codec, precision=None):
# def assert_array_items_equal(res, arr):
# def check_encode_decode_array(arr, codec):
# def check_config(codec):
# def check_repr(stmt):
# def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, prefix=None):
# def check_err_decode_object_buffer(compressor):
# def check_err_encode_object_buffer(compressor):
# def check_max_buffer_size(codec):


import unittest
import numpy as np
import pytest
    from numcodecs.vlen import VLenUTF8
from numcodecs.tests.common import (check_config, check_repr, check_encode_decode_array,
                                    check_backwards_compatibility, greetings,
                                    assert_array_items_equal)
    with pytest.raises(TypeError):
        codec.decode(1234)
    # these should look like corrupt data
    with pytest.raises(ValueError):
        codec.decode(b'foo')
    with pytest.raises(ValueError):
        codec.decode(np.arange(2, 3, dtype='i4'))
    with pytest.raises(ValueError):
        codec.decode(np.arange(10, 20, dtype='i4'))
    with pytest.raises(TypeError):
        codec.decode('foo')

    # test out parameter
    enc = codec.encode(arrays[0])
    with pytest.raises(TypeError):
        codec.decode(enc, out=b'foo')
    with pytest.raises(TypeError):
        codec.decode(enc, out='foo')
    with pytest.raises(TypeError):
        codec.decode(enc, out=123)
    with pytest.raises(ValueError):
        codec.decode(enc, out=np.zeros(10, dtype='i4'))


def test_encode_utf8():
    a = np.array(['foo', None, 'bar'], dtype=object)
    codec = VLenUTF8()
    enc = codec.encode(a)
    dec = codec.decode(enc)
    expect = np.array(['foo', '', 'bar'], dtype=object)

# Path: numcodecs/tests/common.py
# def compare_arrays(arr, res, precision=None):
# def check_encode_decode(arr, codec, precision=None):
# def check_encode_decode_partial(arr, codec, precision=None):
# def assert_array_items_equal(res, arr):
# def check_encode_decode_array(arr, codec):
# def check_config(codec):
# def check_repr(stmt):
# def check_backwards_compatibility(codec_id, arrays, codecs, precision=None, prefix=None):
# def check_err_decode_object_buffer(compressor):
# def check_err_encode_object_buffer(compressor):
# def check_max_buffer_size(codec):


# Path: numcodecs/tests/test_vlen_utf8.py
import unittest
import numpy as np
import pytest
    from numcodecs.vlen import VLenUTF8
from numcodecs.tests.common import (check_config, check_repr, check_encode_decode_array,
                                    check_backwards_compatibility, greetings,
                                    assert_array_items_equal)

    with pytest.raises(TypeError):
        codec.decode(1234)
    # these should look like corrupt data
    with pytest.raises(ValueError):
        codec.decode(b'foo')
    with pytest.raises(ValueError):
        codec.decode(np.arange(2, 3, dtype='i4'))
    with pytest.raises(ValueError):
        codec.decode(np.arange(10, 20, dtype='i4'))
    with pytest.raises(TypeError):
        codec.decode('foo')

    # test out parameter
    enc = codec.encode(arrays[0])
    with pytest.raises(TypeError):
        codec.decode(enc, out=b'foo')
    with pytest.raises(TypeError):
        codec.decode(enc, out='foo')
    with pytest.raises(TypeError):
        codec.decode(enc, out=123)
    with pytest.raises(ValueError):
        codec.decode(enc, out=np.zeros(10, dtype='i4'))


def test_encode_utf8():
    a = np.array(['foo', None, 'bar'], dtype=object)
    codec = VLenUTF8()
    enc = codec.encode(a)
    dec = codec.decode(enc)
    expect = np.array(['foo', '', 'bar'], dtype=object)

    assert_array_items_equal(expect, dec)