public class ByteBufferTest
{
@Test
public void testByteBufferGrowth()
{
ByteBuffer buf = new ByteBuffer();
assertEquals( 10, buf.capacity() );
for ( int ii = 0; ii < 20; ii++ )
{
buf.append( ii );
assertEquals( ii, buf.get( ii ) );
assertEquals( ii, buf.buffer()[ii] );
}
assertEquals( 20, buf.capacity() );
buf.append( 20 );
assertEquals( 30, buf.capacity() );
// -------------------------------------------------------------------
buf = new ByteBuffer( 5 );
assertEquals( 5, buf.capacity() );
for ( int ii = 0; ii < 5; ii++ )
{
buf.append( ii );
assertEquals( ii, buf.get( ii ) );
assertEquals( ii, buf.buffer()[ii] );
}
assertEquals( 5, buf.capacity() );
buf.append( 5 );
assertEquals( 10, buf.capacity() );
}