assertEquals(buffer.capacity(), duplicate.capacity());
assertEquals(num, duplicate.getInt());
}
public void testSlice() {
Buffer buffer = newBuffer(8);
buffer.putInt(123);
Buffer slice = buffer.slice();
assertEquals(0, slice.position());
assertEquals(4, slice.limit());
assertEquals(4, slice.capacity());
assertEquals(4, buffer.position());
assertEquals(8, buffer.limit());
assertEquals(8, buffer.capacity());
int num = random.nextInt();
buffer.putInt(num);
assertEquals(8, buffer.position());
assertEquals(num, slice.getInt());
assertEquals(4, slice.position());
buffer.flip();
slice = buffer.slice();
assertEquals(0, slice.position());
assertEquals(8, slice.limit());
assertEquals(123, slice.getInt());
assertEquals(num, slice.getInt());
assertFalse(slice.hasRemaining());
}