### Question:
Protocol { public static void writeInt(ByteBuffer buf, int n) { if (n < 0) { buf.put((byte) '-'); } n = Math.abs(n); int start = buf.position(); do { buf.put((byte)('0' + n % 10)); n /= 10; } while (n > 0); int end = buf.position(); int i = start; int j = end - 1; while (i < j) { byte tmp = buf.get(i); buf.put(i, buf.get(j)); buf.put(j, tmp); i++; j--; } }  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 writeInt() throws Exception { assertEquals("-123", writeInt(-123)); assertEquals( "0", writeInt(0)); assertEquals( "123", writeInt(123)); }