def test_pack_string():
    b = BytesIO()
    proto.write_val(b, TType.STRING, "hello world!")
    assert_equal("00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21",
                 hexlify(b.getvalue()))

    b = BytesIO()
    proto.write_val(b, TType.STRING, u("你好世界"))
    assert_equal("00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c",
                 hexlify(b.getvalue()))
def test_pack_string():
    b = BytesIO()
    proto.write_val(b, TType.STRING, "hello world!")
    assert_equal("00 00 00 0c 68 65 6c 6c 6f 20 77 6f 72 6c 64 21",
                 hexlify(b.getvalue()))

    b = BytesIO()
    proto.write_val(b, TType.STRING, u("你好世界"))
    assert_equal("00 00 00 0c e4 bd a0 e5 a5 bd e4 b8 96 e7 95 8c",
                 hexlify(b.getvalue()))
def test_pack_double():
    b = BytesIO()
    proto.write_val(b, TType.DOUBLE, 1234567890.1234567890)
    assert_equal("41 d2 65 80 b4 87 e6 b7", hexlify(b.getvalue()))
def test_pack_i64():
    b = BytesIO()
    proto.write_val(b, TType.I64, 1234567890123456789)
    assert_equal("11 22 10 f4 7d e9 81 15", hexlify(b.getvalue()))
def test_pack_i32():
    b = BytesIO()
    proto.write_val(b, TType.I32, 1234567890)
    assert_equal("49 96 02 d2", hexlify(b.getvalue()))
def test_pack_i16():
    b = BytesIO()
    proto.write_val(b, TType.I16, 12345)
    assert_equal("30 39", hexlify(b.getvalue()))
def test_pack_i8():
    b = BytesIO()
    proto.write_val(b, TType.I08, 123)
    assert_equal("7b", hexlify(b.getvalue()))
def test_pack_double():
    b = BytesIO()
    proto.write_val(b, TType.DOUBLE, 1234567890.1234567890)
    assert_equal("41 d2 65 80 b4 87 e6 b7", hexlify(b.getvalue()))
def test_pack_i64():
    b = BytesIO()
    proto.write_val(b, TType.I64, 1234567890123456789)
    assert_equal("11 22 10 f4 7d e9 81 15", hexlify(b.getvalue()))
def test_pack_i32():
    b = BytesIO()
    proto.write_val(b, TType.I32, 1234567890)
    assert_equal("49 96 02 d2", hexlify(b.getvalue()))
def test_pack_i16():
    b = BytesIO()
    proto.write_val(b, TType.I16, 12345)
    assert_equal("30 39", hexlify(b.getvalue()))
def test_pack_i8():
    b = BytesIO()
    proto.write_val(b, TType.I08, 123)
    assert_equal("7b", hexlify(b.getvalue()))