super(name);
}
public void testCharBuffer()
{
CharBuffer buffer = new CharBuffer();
assertTrue("Test if read is not possible", !buffer.available());
char[] chars1 = "abcde".toCharArray();
buffer.push(chars1, 1, 3); // "bcd"
assertTrue("Test if read is possible", buffer.available());
assertEquals("Test text", 'b', buffer.read());
char[] chars2 = "fghij".toCharArray();
buffer.push(chars2, 2, 3); // "hij"
assertEquals("Test text", 'c', buffer.read());
assertEquals("Test text", 'd', buffer.read());
assertEquals("Test text", 'h', buffer.read());
assertEquals("Test text", 'i', buffer.read());
assertTrue("Test if read is possible", buffer.available());
assertEquals("Test text", 'j', buffer.read());
assertTrue("Test if read is not possible", !buffer.available());
try
{
buffer.read();
fail("Test for IllegalStateException");
}
catch (IllegalStateException e) {}
char[] chars3 = "klmno".toCharArray();
buffer.push(chars3, 0, 2); // "kl"
assertTrue("Test if read is possible", buffer.available());
assertEquals("Test text", 'k', buffer.read());
assertEquals("Test text", 'l', buffer.read());
try
{
buffer.read();
fail("Test for IllegalStateException");
}
catch (IllegalStateException e) {}
buffer.back();
assertEquals("Test text", 'l', buffer.peek());
buffer.back();
assertEquals("Test text", 'k', buffer.peek());
assertTrue("Test if read is possible", buffer.available());
buffer.back();
assertEquals("Test text", 'j', buffer.peek());
buffer.back();
assertEquals("Test text", 'i', buffer.peek());
buffer.back();
assertEquals("Test text", 'h', buffer.peek());
buffer.back();
assertEquals("Test text", 'd', buffer.peek());
buffer.back();
assertEquals("Test text", 'c', buffer.peek());
buffer.back();
assertEquals("Test text", 'b', buffer.peek());
assertTrue("Test if read is possible", buffer.available());
try
{
buffer.back();
fail("Test for IllegalStateException");
}
catch (IllegalStateException e) {}
}