Package com.esotericsoftware.kryo.io

Examples of com.esotericsoftware.kryo.io.UnsafeInput


    for (int i = 0; i < 100; i++) {
      write.writeBoolean(true);
      write.writeBoolean(false);
    }

    Input read = new UnsafeInput(write.toBytes());
    for (int i = 0; i < 100; i++) {
      assertEquals(true, read.readBoolean());
      assertEquals(false, read.readBoolean());
    }
  }
View Full Code Here


    write.writeChar((char)8192);
    write.writeChar((char)16384);
    write.writeChar((char)32767);
    write.writeChar((char)65535);

    Input read = new UnsafeInput(write.toBytes());
    assertEquals(0, read.readChar());
    assertEquals(63, read.readChar());
    assertEquals(64, read.readChar());
    assertEquals(127, read.readChar());
    assertEquals(128, read.readChar());
    assertEquals(8192, read.readChar());
    assertEquals(16384, read.readChar());
    assertEquals(32767, read.readChar());
    assertEquals(65535, read.readChar());
  }
View Full Code Here

    write.writeVarInt(65535, true);
    assertEquals(6, write.total());
    write.flush();
    assertEquals(6, os.size());

    Input read = new UnsafeInput(os.toByteArray());
    assertEquals(0, read.readVarInt(true));
    assertEquals(63, read.readVarInt(true));
    assertEquals(64, read.readVarInt(true));
    assertEquals(65535, read.readVarInt(true));
    assertEquals(true, read.eof());
  }
View Full Code Here

  public void testSimpleVarInt() {
      final int value = 39117;
      final Output out = new UnsafeOutput(1024);
      out.writeVarInt(value, true);
      out.flush();
      final Input in = new UnsafeInput(out.toBytes());
      final int actualValue = in.readVarInt(true);
      assertEquals(value, actualValue);
  }
View Full Code Here

        kryoOut.close();
        // U.close(kryoOut, null);

        Input kryoIn = null;

        kryoIn = new UnsafeInput(kryoOut.getBuffer(), 0, kryoOut.position());

        newObj = marsh.readObject(kryoIn, SampleObject.class);
        kryoIn.close();
        // U.close(kryoIn, null);
      }
View Full Code Here

        kryoOut.close();
        // U.close(kryoOut, null);

        Input kryoIn = null;

        kryoIn = new UnsafeInput(kryoOut.getBuffer(), 0, kryoOut.position());

        newObj = marsh.readObject(kryoIn, SampleObject.class);
        kryoIn.close();
        // U.close(kryoIn, null);
      }
View Full Code Here

        kryoOut.close();
        // U.close(kryoOut, null);

        Input kryoIn = null;

        kryoIn = new UnsafeInput(kryoOut.getBuffer(), 0, kryoOut.position());

        newObj = marsh.readObject(kryoIn, SampleObject.class);
        kryoIn.close();
        // U.close(kryoIn, null);
      }
View Full Code Here

    runStringTest(new UnsafeOutput(new ByteArrayOutputStream()));

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

    runStringTest(127);
    runStringTest(256);
    runStringTest(1024 * 1023);
    runStringTest(1024 * 1024);
 
View Full Code Here

      buffer.append((char)i);

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

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

    if (length <= 127) {
      write.clear();
      write.writeAscii(value);
      write.writeAscii(value);
      read = new UnsafeInput(write.toBytes());
      assertEquals(value, read.readStringBuilder().toString());
      assertEquals(value, read.readString());
    }
  }
View Full Code Here

    for (int i = 0; i < 127; i++)
      write.writeString(String.valueOf((char)i));
    for (int i = 0; i < 127; i++)
      write.writeString(String.valueOf((char)i) + "abc");

    Input read = new UnsafeInput(write.toBytes());
    assertEquals("", read.readString());
    assertEquals("1", read.readString());
    assertEquals("22", read.readString());
    assertEquals("uno", read.readString());
    assertEquals("dos", read.readString());
    assertEquals("tres", read.readString());
    assertEquals(null, read.readString());
    assertEquals(value1, read.readString());
    assertEquals(value2, read.readString());
    for (int i = 0; i < 127; i++)
      assertEquals(String.valueOf((char)i), read.readString());
    for (int i = 0; i < 127; i++)
      assertEquals(String.valueOf((char)i) + "abc", read.readString());

    read.rewind();
    assertEquals("", read.readStringBuilder().toString());
    assertEquals("1", read.readStringBuilder().toString());
    assertEquals("22", read.readStringBuilder().toString());
    assertEquals("uno", read.readStringBuilder().toString());
    assertEquals("dos", read.readStringBuilder().toString());
    assertEquals("tres", read.readStringBuilder().toString());
    assertEquals(null, read.readStringBuilder());
    assertEquals(value1, read.readStringBuilder().toString());
    assertEquals(value2, read.readStringBuilder().toString());
    for (int i = 0; i < 127; i++)
      assertEquals(String.valueOf((char)i), read.readStringBuilder().toString());
    for (int i = 0; i < 127; i++)
      assertEquals(String.valueOf((char)i) + "abc", read.readStringBuilder().toString());
  }
View Full Code Here

TOP

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

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.