Serializer { public void writeDouble(double d) { BigEndianCodec.putDouble(_getBuffer(8), _index, d); _index += 8; } Serializer(); ByteBuffer toByteBuffer(); void writeBoolean(boolean b); void writeByte(byte b); void writeChar(char c); void writeDouble(double d); void writeFloat(float f); void writeInt(int i); void writeLong(long l); void writeObject(Serializable serializable); void writeShort(short s); void writeString(String s); void writeTo(OutputStream outputStream);  }
@Test public void testWriteDouble() { Serializer serializer = new Serializer(); ByteBuffer byteBuffer = ByteBuffer.allocate(_COUNT * 8); byteBuffer.order(ByteOrder.BIG_ENDIAN); DoubleBuffer doubleBuffer = byteBuffer.asDoubleBuffer(); double[] doubles = new double[_COUNT]; for (int i = 0; i < _COUNT; i++) { doubles[i] = _random.nextDouble(); serializer.writeDouble(doubles[i]); doubleBuffer.put(doubles[i]); } ByteBuffer serializerByteBuffer = serializer.toByteBuffer(); Assert.assertArrayEquals( byteBuffer.array(), serializerByteBuffer.array()); }