예제 #1
0
def test_unpack_i32():
    b = BytesIO(b"I\x96\x02\xd2")
    assert 1234567890 == proto.read_val(b, TType.I32)
예제 #2
0
def test_unpack_i16():
    b = BytesIO(b"09")
    assert_equal(12345, proto.read_val(b, TType.I16))
예제 #3
0
def test_unpack_i16():
    b = BytesIO(b"09")
    assert 12345 == proto.read_val(b, TType.I16)
예제 #4
0
def test_unpack_i32():
    b = BytesIO(b'I\x96\x02\xd2')
    assert_equal(1234567890, proto.read_val(b, TType.I32))
예제 #5
0
def test_unpack_double():
    b = BytesIO(b'A\xd2e\x80\xb4\x87\xe6\xb7')
    assert_equal(1234567890.1234567890, proto.read_val(b, TType.DOUBLE))
예제 #6
0
def test_unpack_string():
    b = BytesIO(b"\x00\x00\x00\x0c"
                b"\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xb8\x96\xe7\x95\x8c")
    assert u("你好世界") == proto.read_val(b, TType.STRING)
예제 #7
0
def test_unpack_i8():
    b = BytesIO(b"{")
    assert_equal(123, proto.read_val(b, TType.I08))
예제 #8
0
def test_unpack_i8():
    b = BytesIO(b"{")
    assert 123 == proto.read_val(b, TType.I08)
예제 #9
0
def test_unpack_i16():
    b = BytesIO(b"09")
    assert 12345 == proto.read_val(b, TType.I16)
예제 #10
0
def test_unpack_string():
    b = BytesIO(b'\x00\x00\x00\x0c'
                b'\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xb8\x96\xe7\x95\x8c')
    assert_equal(u("你好世界"), proto.read_val(b, TType.STRING))
예제 #11
0
def test_unpack_binary():
    bs = BytesIO(b"\x00\x00\x00\x0c"
                 b"\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xb8\x96\xe7\x95\x8c")
    assert u("你好世界").encode("utf-8") == proto.read_val(bs,
                                                       TType.STRING,
                                                       decode_response=False)
예제 #12
0
def test_unpack_double():
    b = BytesIO(b'A\xd2e\x80\xb4\x87\xe6\xb7')
    assert_equal(1234567890.1234567890, proto.read_val(b, TType.DOUBLE))
예제 #13
0
def test_unpack_i64():
    b = BytesIO(b'\x11"\x10\xf4}\xe9\x81\x15')
    assert_equal(1234567890123456789, proto.read_val(b, TType.I64))
예제 #14
0
def test_unpack_i32():
    b = BytesIO(b'I\x96\x02\xd2')
    assert_equal(1234567890, proto.read_val(b, TType.I32))
예제 #15
0
def test_unpack_i64():
    b = BytesIO(b"\x11\"\x10\xf4}\xe9\x81\x15")
    assert 1234567890123456789 == proto.read_val(b, TType.I64)
예제 #16
0
def test_unpack_i32():
    b = BytesIO(b"I\x96\x02\xd2")
    assert 1234567890 == proto.read_val(b, TType.I32)
예제 #17
0
def test_unpack_double():
    b = BytesIO(b"A\xd2e\x80\xb4\x87\xe6\xb7")
    assert 1234567890.1234567890 == proto.read_val(b, TType.DOUBLE)
예제 #18
0
def test_unpack_i64():
    b = BytesIO(b"\x11\"\x10\xf4}\xe9\x81\x15")
    assert 1234567890123456789 == proto.read_val(b, TType.I64)
예제 #19
0
def test_unpack_binary():
    bs = BytesIO(b"\x00\x00\x00\x0c"
                 b"\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xb8\x96\xe7\x95\x8c")
    assert u("你好世界").encode("utf-8") == proto.read_val(
        bs, TType.STRING, decode_response=False)
예제 #20
0
def test_unpack_double():
    b = BytesIO(b"A\xd2e\x80\xb4\x87\xe6\xb7")
    assert 1234567890.1234567890 == proto.read_val(b, TType.DOUBLE)
예제 #21
0
def test_unpack_i16():
    b = BytesIO(b"09")
    assert_equal(12345, proto.read_val(b, TType.I16))
예제 #22
0
def test_unpack_string():
    b = BytesIO(b"\x00\x00\x00\x0c"
                b"\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xb8\x96\xe7\x95\x8c")
    assert u("你好世界") == proto.read_val(b, TType.STRING)
예제 #23
0
def test_unpack_i64():
    b = BytesIO(b'\x11"\x10\xf4}\xe9\x81\x15')
    assert_equal(1234567890123456789, proto.read_val(b, TType.I64))
예제 #24
0
def test_unpack_i8():
    b = BytesIO(b"{")
    assert 123 == proto.read_val(b, TType.I08)
예제 #25
0
def test_unpack_string():
    b = BytesIO(b'\x00\x00\x00\x0c'
                b'\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xb8\x96\xe7\x95\x8c')
    assert_equal(u("你好世界"), proto.read_val(b, TType.STRING))
예제 #26
0
def test_unpack_i8():
    b = BytesIO(b"{")
    assert_equal(123, proto.read_val(b, TType.I08))