buffer.clear();
buffer.limit(random.nextInt(buffer.capacity()));
buffer.position(random.nextInt(buffer.limit()));
buffer = buffer.slice();
ByteBuffer b3 = buffer.asByteBuffer();
assertEquals(buffer.position(), b3.position());
assertEquals(buffer.limit(), b3.limit());
assertEquals(buffer.capacity(), b3.capacity());
while (b3.hasRemaining())
assertEquals(b3.get(), buffer.get());