Buffer { public Buffer append(char ch) { return this.append(String.valueOf(ch)); } Buffer(); static Buffer init(); int length(); Buffer append(char ch); Buffer append(String str); Buffer insert(int pos, String str); Buffer clear(); char[] value(); @Override String toString(); static final String BUFFER_TYPENAME; static final String BUFFER_DESC; }
@Test public void appendingNullStringShouldThrowRuntimeException() { String str = null; Buffer buffer = new Buffer(); thrown.expect(RuntimeException.class); thrown.expectMessage(equalTo("String sent to the buffer was null.")); buffer.append(str); }