### Question:
Protocol { public static int parseInt(ByteBuffer buf, byte delimiter) { int sign = 1; if (buf.get(buf.position()) == (byte)'-') { buf.get(); sign = -1; } int result = 0; for (;;) { byte ch = buf.get(); if (ch == delimiter) { break; } result *= 10; result += (byte)ch - (byte)'0'; } return sign * result; }  static void format(ByteBuffer buf, int tag, byte[] value); static void formatInt(ByteBuffer buf, int tag, int value); static void formatString(ByteBuffer buf, int tag, String value); static void formatCheckSum(ByteBuffer buf, int tag, int value); static void writeInt(ByteBuffer buf, int n); static void match(ByteBuffer buf, int tag); static int matchInt(ByteBuffer buf, int tag); static int parseInt(ByteBuffer buf, byte delimiter); static ByteString parseString(ByteBuffer buf, byte delimiter); static MessageType matchMsgType(ByteBuffer buf); static void matchTag(ByteBuffer buf, int tag); static final int MAX_HEADER_SIZE; static final int MAX_BODY_SIZE; }### Answer:
@Test public void parseInt() throws Exception { assertEquals(-123, parseInt("-123\1")); assertEquals( 0, parseInt("0\1")); assertEquals( 123, parseInt("123\1")); }