コード例 #1
0
ファイル: InputOutputTest.java プロジェクト: esialb/kryo
  public void runStringTest(int length) throws IOException {
    Output write = new Output(1024, -1);
    StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < length; i++) buffer.append((char) i);

    String value = buffer.toString();
    write.writeString(value);
    write.writeString(value);
    Input read = new Input(write.toBytes());
    assertEquals(value, read.readString());
    assertEquals(value, read.readStringBuilder().toString());

    write.clear();
    write.writeString(buffer);
    write.writeString(buffer);
    read = new Input(write.toBytes());
    assertEquals(value, read.readStringBuilder().toString());
    assertEquals(value, read.readString());

    if (length <= 127) {
      write.clear();
      write.writeAscii(value);
      write.writeAscii(value);
      read = new Input(write.toBytes());
      assertEquals(value, read.readStringBuilder().toString());
      assertEquals(value, read.readString());
    }
  }
コード例 #2
0
 public void write(Kryo kryo, Output output, Locale l) {
   output.writeAscii(l.getLanguage());
   output.writeAscii(l.getCountry());
   output.writeString(l.getVariant());
 }