def test_unpack_i32():
    b = BytesIO(b"I\x96\x02\xd2")
    assert 1234567890 == proto.read_val(b, TType.I32)
def test_unpack_i16():
    b = BytesIO(b"09")
    assert_equal(12345, proto.read_val(b, TType.I16))
def test_unpack_i16():
    b = BytesIO(b"09")
    assert 12345 == proto.read_val(b, TType.I16)
def test_unpack_i32():
    b = BytesIO(b'I\x96\x02\xd2')
    assert_equal(1234567890, proto.read_val(b, TType.I32))
def test_unpack_double():
    b = BytesIO(b'A\xd2e\x80\xb4\x87\xe6\xb7')
    assert_equal(1234567890.1234567890, proto.read_val(b, TType.DOUBLE))
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)
def test_unpack_i8():
    b = BytesIO(b"{")
    assert_equal(123, proto.read_val(b, TType.I08))
def test_unpack_i8():
    b = BytesIO(b"{")
    assert 123 == proto.read_val(b, TType.I08)
def test_unpack_i16():
    b = BytesIO(b"09")
    assert 12345 == proto.read_val(b, TType.I16)
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))
Exemple #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)
def test_unpack_double():
    b = BytesIO(b'A\xd2e\x80\xb4\x87\xe6\xb7')
    assert_equal(1234567890.1234567890, proto.read_val(b, TType.DOUBLE))
def test_unpack_i64():
    b = BytesIO(b'\x11"\x10\xf4}\xe9\x81\x15')
    assert_equal(1234567890123456789, proto.read_val(b, TType.I64))
def test_unpack_i32():
    b = BytesIO(b'I\x96\x02\xd2')
    assert_equal(1234567890, proto.read_val(b, TType.I32))
def test_unpack_i64():
    b = BytesIO(b"\x11\"\x10\xf4}\xe9\x81\x15")
    assert 1234567890123456789 == proto.read_val(b, TType.I64)
def test_unpack_i32():
    b = BytesIO(b"I\x96\x02\xd2")
    assert 1234567890 == proto.read_val(b, TType.I32)
def test_unpack_double():
    b = BytesIO(b"A\xd2e\x80\xb4\x87\xe6\xb7")
    assert 1234567890.1234567890 == proto.read_val(b, TType.DOUBLE)
def test_unpack_i64():
    b = BytesIO(b"\x11\"\x10\xf4}\xe9\x81\x15")
    assert 1234567890123456789 == proto.read_val(b, TType.I64)
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)
def test_unpack_double():
    b = BytesIO(b"A\xd2e\x80\xb4\x87\xe6\xb7")
    assert 1234567890.1234567890 == proto.read_val(b, TType.DOUBLE)
def test_unpack_i16():
    b = BytesIO(b"09")
    assert_equal(12345, proto.read_val(b, TType.I16))
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)
def test_unpack_i64():
    b = BytesIO(b'\x11"\x10\xf4}\xe9\x81\x15')
    assert_equal(1234567890123456789, proto.read_val(b, TType.I64))
def test_unpack_i8():
    b = BytesIO(b"{")
    assert 123 == proto.read_val(b, TType.I08)
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))
def test_unpack_i8():
    b = BytesIO(b"{")
    assert_equal(123, proto.read_val(b, TType.I08))