4647484950515253545556
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());
6263646566676869707172
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());
8081828384858687888990
for ( int ii = 0; ii < 20; ii++ ) { buf.append( ii ); assertEquals(ii, buf.get(ii)); assertEquals(ii, buf.buffer()[ii]); assertEquals(ii, buf.copyOfUsedBytes()[ii]); } } public void testAppendByteArray()
9293949596979899100101
ByteBuffer buf = new ByteBuffer(); buf.append( new byte[]{ 0, 1, 2, 3, 4 } ); for ( int ii = 0; ii < 5; ii++ ) { assertEquals(ii, buf.get(ii)); assertEquals(ii, buf.buffer()[ii]); assertEquals(ii, buf.copyOfUsedBytes()[ii]); } } }
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() );
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() );
8182838485868788899091
for ( int ii = 0; ii < 20; ii++ ) { buf.append( ii ); assertEquals( ii, buf.get( ii ) ); assertEquals( ii, buf.buffer()[ii] ); assertEquals( ii, buf.copyOfUsedBytes()[ii] ); } }
9596979899100101102103104
buf.append( new byte[] { 0, 1, 2, 3, 4 } ); for ( int ii = 0; ii < 5; ii++ ) { assertEquals( ii, buf.get( ii ) ); assertEquals( ii, buf.buffer()[ii] ); assertEquals( ii, buf.copyOfUsedBytes()[ii] ); } } }