Example #1
0
def test_set_length_1_min():
    base = Base(b'\x82', b'a' * 0x80)
    assert base.length == 0x80
Example #2
0
def test_set_length_1_max_raw():
    base = Base(b'\x82', b'a' * 0xFF)
    assert base.raw_length == b'\x81\xFF'
Example #3
0
def test_set_length_0_max():
    base = Base(b'\x82', b'a' * 0x79)
    assert base.length == 0x79
Example #4
0
def test_set_length_1_min_raw():
    base = Base(b'\x82', b'a' * 0x80)
    assert base.raw_length == b'\x81\x80'
Example #5
0
def empty_value():
    return Base(b'\x80')
Example #6
0
def test_set_length_0_max_raw():
    base = Base(b'\x82', b'a' * 0x79)
    assert base.raw_length == b'\x79'
Example #7
0
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
Example #8
0
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
Example #9
0
def test_set_raw_value_type_error():
    with raises(TypeError):
        Base(b'\x84', 'string')
Example #10
0
def test_set_length_value_error():
    with raises(ValueError):
        Base(b'\x85', b'a' * 0x1FFFF)
Example #11
0
def test_set_tag_type_error():
    with raises(TypeError):
        Base('\x83')
Example #12
0
def test_set_tag_value_error_above():
    with raises(ValueError):
        Base(b'\x00\x00')
Example #13
0
def test_set_tag_value_error_below():
    with raises(ValueError):
        Base(b'')
Example #14
0
def generic():
    return Base(b'\x81', b'string')
Example #15
0
def test_set_length_2_min_raw():
    base = Base(b'\x82', b'a' * 0x1FF)
    assert base.raw_length == b'\x82\x01\xFF'