Serializer { public void writeFloat(float f) { BigEndianCodec.putFloat(_getBuffer(4), _index, f); _index += 4; } 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 testWriteFloat() { Serializer serializer = new Serializer(); ByteBuffer byteBuffer = ByteBuffer.allocate(_COUNT * 4); byteBuffer.order(ByteOrder.BIG_ENDIAN); FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); float[] floats = new float[_COUNT]; for (int i = 0; i < _COUNT; i++) { floats[i] = _random.nextFloat(); serializer.writeFloat(floats[i]); floatBuffer.put(floats[i]); } ByteBuffer serializerByteBuffer = serializer.toByteBuffer(); Assert.assertArrayEquals( byteBuffer.array(), serializerByteBuffer.array()); }