def test_set_length_1_min(): base = Base(b'\x82', b'a' * 0x80) assert base.length == 0x80
def test_set_length_1_max_raw(): base = Base(b'\x82', b'a' * 0xFF) assert base.raw_length == b'\x81\xFF'
def test_set_length_0_max(): base = Base(b'\x82', b'a' * 0x79) assert base.length == 0x79
def test_set_length_1_min_raw(): base = Base(b'\x82', b'a' * 0x80) assert base.raw_length == b'\x81\x80'
def empty_value(): return Base(b'\x80')
def test_set_length_0_max_raw(): base = Base(b'\x82', b'a' * 0x79) assert base.raw_length == b'\x79'
def test_a_c_b(): a, b, c = Base.unpack_extra_value((b'1', 3), 2) assert a == b'1' and b == 2 and c == 3
def test_a_none_b_c(): a, b, c = Base.unpack_extra_value((b'1', None), (2, 3)) assert a == b'1' and b == 2 and c == 3
def test_set_raw_value_type_error(): with raises(TypeError): Base(b'\x84', 'string')
def test_set_length_value_error(): with raises(ValueError): Base(b'\x85', b'a' * 0x1FFFF)
def test_set_tag_type_error(): with raises(TypeError): Base('\x83')
def test_set_tag_value_error_above(): with raises(ValueError): Base(b'\x00\x00')
def test_set_tag_value_error_below(): with raises(ValueError): Base(b'')
def generic(): return Base(b'\x81', b'string')
def test_set_length_2_min_raw(): base = Base(b'\x82', b'a' * 0x1FF) assert base.raw_length == b'\x82\x01\xFF'