### Question:
ProtoUtils { public static int readInt(ByteBuf buffer) throws IndexOutOfBoundsException { long size = 0; boolean isNeg = false; byte b =buffer.readByte(); while (b != '\r') { if (b == '-') { isNeg = true; } else { size = size * 10 + b - '0'; } b = buffer.readByte(); } buffer.readByte(); size = (isNeg ? -size : size); if (size > Integer.MAX_VALUE) { throw new RuntimeException("Cannot allocate more than " + Integer.MAX_VALUE + " bytes"); } if (size < Integer.MIN_VALUE) { throw new RuntimeException("Cannot allocate less than " + Integer.MIN_VALUE + " bytes"); } return (int) size; }  static byte[] convertIntToByteArray(int value); static byte[] buildErrorReplyBytes(String message); static int readInt(ByteBuf buffer); static final byte[] OK; static final byte[] PONG; static final byte[] ERR_NO_AUTH; static final byte[] ERR_NO_AUTH_PASSWORD; static final byte[] ERR_NO_AUTH_NO_PASSWORD; static final byte[] ERR_PIPELINE_BACKEND; static final byte[] ERR_INVALID_COMMAND; static final byte[] ERROR_ERR_BULK; static final byte[] WRONGTYPE_ERR_BULK; static final byte[] NOIMPLEMENT_ERR_BULK; }### Answer:
@Test public void readIn(){ ByteBuf buf = Unpooled.buffer(); buf.writeBytes("100\r\n".getBytes()); int v=ProtoUtils.readInt(buf); assertEquals(100,v); assertEquals( buf.writerIndex(),buf.readerIndex()); buf.resetWriterIndex(); buf.resetReaderIndex(); buf.writeBytes("-100\r\n".getBytes()); v=ProtoUtils.readInt(buf); assertEquals(-100,v); assertEquals( buf.writerIndex(),buf.readerIndex()); }