Example #1
0
  public void testEncodeFloat64() throws IOException {
    final double[] input = new double[] {0.D, 1.D, 64.5D};
    final byte[] expected =
        new byte[] {
          (byte) 0x00,
          (byte) 0xc0,
          (byte) 0xf0,
          (byte) 0x3f,
          (byte) 0xe0,
          (byte) 0x20,
          (byte) 0x50,
          (byte) 0x40,
        };

    ByteArrayOutputStream output = new ByteArrayOutputStream(expected.length);
    Encoder e = new Encoder(output);

    for (double f64 : input) {
      e.float64(f64);
    }
    Assert.assertArrayEquals(expected, output.toByteArray());
  }