### Question:
MemcmpDecoder extends Decoder { @Override public long readLong() throws IOException { byte[] longBytes = new byte[8]; int i = in.read(longBytes); if (i < 8) { throw new EOFException(); } longBytes[0] = (byte) (longBytes[0] ^ 0x80); long value = 0; for (int j = 0; j < longBytes.length; ++j) { value = (value << 8) + (longBytes[j] & 0xff); } return value; } MemcmpDecoder(InputStream in); @Override void readNull(); @Override boolean readBoolean(); @Override int readInt(); @Override long readLong(); @Override float readFloat(); @Override double readDouble(); @Override Utf8 readString(Utf8 old); @Override String readString(); @Override void skipString(); @Override ByteBuffer readBytes(ByteBuffer old); void skipBytes(); @Override void readFixed(byte[] bytes, int start, int length); @Override void skipFixed(int length); @Override int readEnum(); @Override long readArrayStart(); @Override long arrayNext(); @Override long skipArray(); @Override long readMapStart(); @Override long mapNext(); @Override long skipMap(); @Override int readIndex();  }### Answer:
@Test public void testDecodeLong() throws Exception { InputStream in = new ByteArrayInputStream(new byte[] { (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 }); Decoder decoder = new MemcmpDecoder(in); long i = decoder.readLong(); assertEquals(1L, i); in = new ByteArrayInputStream(new byte[] { (byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff }); decoder = new MemcmpDecoder(in); i = decoder.readLong(); assertEquals(-1L, i); in = new ByteArrayInputStream(new byte[] { (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }); decoder = new MemcmpDecoder(in); i = decoder.readLong(); assertEquals(0L, i); }