Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.Output


        51, 52, 53, 54, 55, 56, 57, 58, //
        61, 62, 63, 64, 65}, buffer.toBytes());
  }

  public void testStrings () throws IOException {
    runStringTest(new Output(4096));
    runStringTest(new Output(897));
    runStringTest(new Output(new ByteArrayOutputStream()));

    Output write = new Output(21);
    String value = "abcdef\u00E1\u00E9\u00ED\u00F3\u00FA\u1234";
    write.writeString(value);
    Input read = new Input(write.toBytes());
    assertEquals(value, read.readString());

    write.clear();
    write.writeString(null);
    read = new Input(write.toBytes());
    assertEquals(null, read.readString());

    for (int i = 0; i <= 258; i++)
      runStringTest(i);
    runStringTest(1);
View Full Code Here


    runStringTest(1024 * 1026);
    runStringTest(1024 * 1024 * 2);
  }

  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());
    }
  }
View Full Code Here

    for (int i = 0; i < 127; i++)
      assertEquals(String.valueOf((char)i) + "abc", read.readStringBuilder().toString());
  }

  public void testCanReadInt () throws IOException {
    Output write = new Output(new ByteArrayOutputStream());

    Input read = new Input(write.toBytes());
    assertEquals(false, read.canReadInt());

    write.writeInt(400, true);

    read = new Input(write.toBytes());
    assertEquals(true, read.canReadInt());
    read.setLimit(read.limit() - 1);
    assertEquals(false, read.canReadInt());
  }
View Full Code Here

    read.setLimit(read.limit() - 1);
    assertEquals(false, read.canReadInt());
  }

  public void testInts () throws IOException {
    runIntTest(new Output(4096));
    runIntTest(new Output(new ByteArrayOutputStream()));
  }
View Full Code Here

      assertEquals(value, read.readInt(false));
    }
  }

  public void testLongs () throws IOException {
    runLongTest(new Output(4096));
    runLongTest(new Output(new ByteArrayOutputStream()));
  }
View Full Code Here

      assertEquals(value, read.readLong(false));
    }
  }

  public void testShorts () throws IOException {
    runShortTest(new Output(4096));
    runShortTest(new Output(new ByteArrayOutputStream()));
  }
View Full Code Here

    assertEquals(-16384, read.readShort());
    assertEquals(-32768, read.readShort());
  }

  public void testFloats () throws IOException {
    runFloatTest(new Output(4096));
    runFloatTest(new Output(new ByteArrayOutputStream()));
  }
View Full Code Here

    assertEquals(read.readFloat(1000, false), -8192f);
    assertEquals(read.readFloat(1000, true), -8192f);
  }

  public void testDoubles () throws IOException {
    runDoubleTest(new Output(4096));
    runDoubleTest(new Output(new ByteArrayOutputStream()));
  }
View Full Code Here

    assertEquals(read.readDouble(1000, true), -8192d);
    assertEquals(1.23456d, read.readDouble());
  }

  public void testBooleans () throws IOException {
    runBooleanTest(new Output(4096));
    runBooleanTest(new Output(new ByteArrayOutputStream()));
  }
View Full Code Here

      assertEquals(false, read.readBoolean());
    }
  }

  public void testChars () throws IOException {
    runCharTest(new Output(4096));
    runCharTest(new Output(new ByteArrayOutputStream()));
  }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.io.Output

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.