blob: 6dda7f60b872b7af2041e2f10f05b82c69b68969 [file]
package org.codehaus.jackson.util;
public class TestTextBuffer
extends main.BaseTest
{
/**
* Trivially simple basic test to ensure all basic append
* methods work
*/
public void testSimple()
{
TextBuffer tb = new TextBuffer(new BufferRecycler());
tb.append('a');
tb.append(new char[] { 'X', 'b' }, 1, 1);
tb.append("c", 0, 1);
assertEquals(3, tb.contentsAsArray().length);
assertEquals("abc", tb.toString());
assertNotNull(tb.expandCurrentSegment());
}
public void testLonger()
{
TextBuffer tb = new TextBuffer(new BufferRecycler());
for (int i = 0; i < 2000; ++i) {
tb.append("abc", 0, 3);
}
String str = tb.contentsAsString();
assertEquals(6000, str.length());
assertEquals(6000, tb.contentsAsArray().length);
tb.resetWithShared(new char[] { 'a' }, 0, 1);
assertEquals(1, tb.toString().length());
}
}