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