Beispiel #1
0
def test_Array_can_parse_empty_array_with_normal_format():
    # This is generally not sent by the server, because empty arrays
    # are sent as "0 *", but I think we should handle it anyway.
    s = MockSocket(b"0 { }")
    buf = ReceiveBuffer(s)
    res = ArrayInt32.parse(buf)
    assert res == []
Beispiel #2
0
def test_Array_can_parse_array_non_zero_length_with_star_special_case():
    s = MockSocket(b"5 *") # length 5 but no array content
    buf = ReceiveBuffer(s)
    res = ArrayInt32.parse(buf)
    assert res == []
Beispiel #3
0
def test_ArrayInt32_extend_convert_element():
    a = ArrayInt32([1, 2, 3])
    b = [4, 5, 6]
    a.extend(b)
    assert a.to_string() == b"6 { 1 2 3 4 5 6 }"
Beispiel #4
0
def test_ArrayInt32_add_convert_element():
    a = ArrayInt32([1, 2, 3])
    b = [4, 5, 6]
    a = a + b
    assert a.to_string() == b"6 { 1 2 3 4 5 6 }"
Beispiel #5
0
def test_ArrayInt32_add():
    a = ArrayInt32([1, 2, 3])
    b = ArrayInt32([4, 5, 6])
    a = a + b
    assert a.to_string() == b"6 { 1 2 3 4 5 6 }"
Beispiel #6
0
def test_ArrayInt32_insert_convert_element():
    a = ArrayInt32()
    a.insert(0, 17)
    a.insert(1, 4711)
    assert a.to_string() == b"2 { 17 4711 }"
Beispiel #7
0
def test_ArrayInt32_append_convert_element():
    a = ArrayInt32()
    a.append(17)
    a.append(4711)
    assert a.to_string() == b"2 { 17 4711 }"
Beispiel #8
0
def test_ArrayInt32_setitem_convert_element():
    a = ArrayInt32([0, 0])
    a[0] = 17
    a[1] = 4711
    assert a.to_string() == b"2 { 17 4711 }"
Beispiel #9
0
def test_ArrayInt32_constructor_convert_elements():
    a = ArrayInt32([ 17, 4711, 0 ])
    assert a.to_string() == b"3 { 17 4711 0 }"
Beispiel #10
0
def test_ArrayInt32_empty_array():
    a = ArrayInt32([])
    assert a.to_string() == b"0 { }"
Beispiel #11
0
def test_ArrayInt32_parse():
    a = ArrayInt32.parse(ReceiveBuffer(MockSocket(b"3 { 17 4711 0 }")))
    for v in a:
        assert isinstance(v, Int32)
    assert a.to_string() == b"3 { 17 4711 0 }"
Beispiel #12
0
def test_Array_can_parse_empty_array_with_star_format():
    s = MockSocket([b"0 *"])
    buf = ReceiveBuffer(s)
    res = ArrayInt32.parse(buf)
    assert res == []