@Test
public void testSlice() {

    ByteBuffer bb1 = ByteBuffer.allocate(5);
    bb1.put("012".getBytes());
    bb1.flip();
    ByteBuffer bb2 = ByteBuffer.allocate(5);
    bb2.put("345".getBytes());
    bb2.flip();
    ByteBuffer bb3 = ByteBuffer.allocate(5);
    bb3.put("6789".getBytes());
    bb3.flip();
    IoBuffer ioBuffer = IoBuffer.newInstance();
    ioBuffer.add(bb1, bb2).add(bb3);
    ioBuffer.position(2);
    ioBuffer.limit(8);
    IoBuffer slice = ioBuffer.slice();
    assertEquals(6, slice.remaining());
    assertEquals(0, slice.position());
    assertEquals(6, slice.limit());
    byte seg[] = "234567".getBytes();
    for (int i = 0; i < 6; i++) {
        assertEquals(seg[i], slice.get(i));
    }
}