public Float read(Kryo kryo, Input input, Class<Float> type) {
   return input.readFloat();
 }
Beispiel #2
0
  private void runFloatTest(Output write) throws IOException {
    write.writeFloat(0);
    write.writeFloat(63);
    write.writeFloat(64);
    write.writeFloat(127);
    write.writeFloat(128);
    write.writeFloat(8192);
    write.writeFloat(16384);
    write.writeFloat(32767);
    write.writeFloat(-63);
    write.writeFloat(-64);
    write.writeFloat(-127);
    write.writeFloat(-128);
    write.writeFloat(-8192);
    write.writeFloat(-16384);
    write.writeFloat(-32768);
    assertEquals(1, write.writeFloat(0, 1000, true));
    assertEquals(1, write.writeFloat(0, 1000, false));
    assertEquals(3, write.writeFloat(63, 1000, true));
    assertEquals(3, write.writeFloat(63, 1000, false));
    assertEquals(3, write.writeFloat(64, 1000, true));
    assertEquals(3, write.writeFloat(64, 1000, false));
    assertEquals(3, write.writeFloat(127, 1000, true));
    assertEquals(3, write.writeFloat(127, 1000, false));
    assertEquals(3, write.writeFloat(128, 1000, true));
    assertEquals(3, write.writeFloat(128, 1000, false));
    assertEquals(4, write.writeFloat(8191, 1000, true));
    assertEquals(4, write.writeFloat(8191, 1000, false));
    assertEquals(4, write.writeFloat(8192, 1000, true));
    assertEquals(4, write.writeFloat(8192, 1000, false));
    assertEquals(4, write.writeFloat(16383, 1000, true));
    assertEquals(4, write.writeFloat(16383, 1000, false));
    assertEquals(4, write.writeFloat(16384, 1000, true));
    assertEquals(4, write.writeFloat(16384, 1000, false));
    assertEquals(4, write.writeFloat(32767, 1000, true));
    assertEquals(4, write.writeFloat(32767, 1000, false));
    assertEquals(3, write.writeFloat(-64, 1000, false));
    assertEquals(5, write.writeFloat(-64, 1000, true));
    assertEquals(3, write.writeFloat(-65, 1000, false));
    assertEquals(5, write.writeFloat(-65, 1000, true));
    assertEquals(4, write.writeFloat(-8192, 1000, false));
    assertEquals(5, write.writeFloat(-8192, 1000, true));

    Input read = new Input(write.toBytes());
    assertEquals(read.readFloat(), 0f);
    assertEquals(read.readFloat(), 63f);
    assertEquals(read.readFloat(), 64f);
    assertEquals(read.readFloat(), 127f);
    assertEquals(read.readFloat(), 128f);
    assertEquals(read.readFloat(), 8192f);
    assertEquals(read.readFloat(), 16384f);
    assertEquals(read.readFloat(), 32767f);
    assertEquals(read.readFloat(), -63f);
    assertEquals(read.readFloat(), -64f);
    assertEquals(read.readFloat(), -127f);
    assertEquals(read.readFloat(), -128f);
    assertEquals(read.readFloat(), -8192f);
    assertEquals(read.readFloat(), -16384f);
    assertEquals(read.readFloat(), -32768f);
    assertEquals(read.readFloat(1000, true), 0f);
    assertEquals(read.readFloat(1000, false), 0f);
    assertEquals(read.readFloat(1000, true), 63f);
    assertEquals(read.readFloat(1000, false), 63f);
    assertEquals(read.readFloat(1000, true), 64f);
    assertEquals(read.readFloat(1000, false), 64f);
    assertEquals(read.readFloat(1000, true), 127f);
    assertEquals(read.readFloat(1000, false), 127f);
    assertEquals(read.readFloat(1000, true), 128f);
    assertEquals(read.readFloat(1000, false), 128f);
    assertEquals(read.readFloat(1000, true), 8191f);
    assertEquals(read.readFloat(1000, false), 8191f);
    assertEquals(read.readFloat(1000, true), 8192f);
    assertEquals(read.readFloat(1000, false), 8192f);
    assertEquals(read.readFloat(1000, true), 16383f);
    assertEquals(read.readFloat(1000, false), 16383f);
    assertEquals(read.readFloat(1000, true), 16384f);
    assertEquals(read.readFloat(1000, false), 16384f);
    assertEquals(read.readFloat(1000, true), 32767f);
    assertEquals(read.readFloat(1000, false), 32767f);
    assertEquals(read.readFloat(1000, false), -64f);
    assertEquals(read.readFloat(1000, true), -64f);
    assertEquals(read.readFloat(1000, false), -65f);
    assertEquals(read.readFloat(1000, true), -65f);
    assertEquals(read.readFloat(1000, false), -8192f);
    assertEquals(read.readFloat(1000, true), -8192f);
  }