@Test public void testBuffer() { MessageBuffer b = new MessageBuffer(); b.append("Hello, world"); b.appendNewLine(); b.append("how are you?"); CharSequence s = b.getBuffer(); assertEquals("Hello, world\nhow are you?", s.toString()); }
@Test public void testMaxSize() { int max = 5; MessageBuffer b = new MessageBuffer(5); for (int i = 0; i < max * 2; i++) { b.append("Line" + i + "\n"); } String content = b.getBuffer().toString(); String expected = "(...)\nLine5\nLine6\nLine7\nLine8\nLine9\n"; assertEquals(expected, content); }