### Question:
Buffer implements BufferedSource, BufferedSink, Cloneable { @Override public String toString() { if (size == 0) { return "Buffer[size=0]"; } if (size <= 16) { ByteString data = clone().readByteString(); return String.format("Buffer[size=%s data=%s]", size, data.hex()); } MessageDigest md5 = new MessageDigest("MD5"); md5.update(head.data, head.pos, head.limit - head.pos); for (Segment s = head.next; s != head; s = s.next) { md5.update(s.data, s.pos, s.limit - s.pos); } return String.format("Buffer[size=%s md5=%s]", size, ByteString.of(md5.digest()).hex()); } Buffer(); long size(); @Override Buffer buffer(); @Override OutputStream outputStream(); @Override Buffer emitCompleteSegments(); @Override BufferedSink emit(); @Override boolean exhausted(); @Override void require(long byteCount); @Override boolean request(long byteCount); @Override InputStream inputStream(); Buffer copyTo(OutputStream out); Buffer copyTo(OutputStream out, long offset, long byteCount); Buffer copyTo(Buffer out, long offset, long byteCount); Buffer writeTo(OutputStream out); Buffer writeTo(OutputStream out, long byteCount); Buffer readFrom(InputStream in); Buffer readFrom(InputStream in, long byteCount); long completeSegmentByteCount(); @Override byte readByte(); byte getByte(long pos); @Override short readShort(); @Override int readInt(); @Override long readLong(); @Override short readShortLe(); @Override int readIntLe(); @Override long readLongLe(); @Override long readDecimalLong(); @Override long readHexadecimalUnsignedLong(); @Override ByteString readByteString(); @Override ByteString readByteString(long byteCount); @Override void readFully(Buffer sink, long byteCount); @Override long readAll(Sink sink); @Override String readUtf8(); @Override String readUtf8(long byteCount); @Override String readString(Charset charset); @Override String readString(long byteCount, Charset charset); @Override String readUtf8Line(); @Override String readUtf8LineStrict(); @Override int readUtf8CodePoint(); @Override byte[] readByteArray(); @Override byte[] readByteArray(long byteCount); @Override int read(byte[] sink); @Override void readFully(byte[] sink); @Override int read(byte[] sink, int offset, int byteCount); void clear(); @Override void skip(long byteCount); @Override Buffer write(ByteString byteString); @Override Buffer writeUtf8(String string); @Override Buffer writeUtf8(String string, int beginIndex, int endIndex); @Override Buffer writeUtf8CodePoint(int codePoint); @Override Buffer writeString(String string, Charset charset); @Override Buffer writeString(String string, int beginIndex, int endIndex, Charset charset); @Override Buffer write(byte[] source); @Override Buffer write(byte[] source, int offset, int byteCount); @Override long writeAll(Source source); @Override BufferedSink write(Source source, long byteCount); @Override Buffer writeByte(int b); @Override Buffer writeShort(int s); @Override Buffer writeShortLe(int s); @Override Buffer writeInt(int i); @Override Buffer writeIntLe(int i); @Override Buffer writeLong(long v); @Override Buffer writeLongLe(long v); @Override Buffer writeDecimalLong(long v); @Override Buffer writeHexadecimalUnsignedLong(long v); @Override void write(Buffer source, long byteCount); @Override long read(Buffer sink, long byteCount); @Override long indexOf(byte b); @Override long indexOf(byte b, long fromIndex); @Override long indexOf(ByteString bytes); @Override long indexOf(ByteString bytes, long fromIndex); @Override long indexOfElement(ByteString targetBytes); @Override long indexOfElement(ByteString targetBytes, long fromIndex); @Override void flush(); @Override void close(); @Override Timeout timeout(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override Buffer clone(); ByteString snapshot(); ByteString snapshot(int byteCount);  }### Answer:
@Test public void toStringOnEmptyBuffer() throws Exception { Buffer buffer = new Buffer(); assertEquals("Buffer[size=0]", buffer.toString()); }