@Test
 public void testDiscardReadBytes3() {
   ByteBuf a, b;
   a = wrappedBuffer(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}).order(order);
   b =
       freeLater(
           wrappedBuffer(
               wrappedBuffer(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 0, 5).order(order),
               wrappedBuffer(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 5, 5).order(order)));
   a.skipBytes(6);
   a.markReaderIndex();
   b.skipBytes(6);
   b.markReaderIndex();
   assertEquals(a.readerIndex(), b.readerIndex());
   a.readerIndex(a.readerIndex() - 1);
   b.readerIndex(b.readerIndex() - 1);
   assertEquals(a.readerIndex(), b.readerIndex());
   a.writerIndex(a.writerIndex() - 1);
   a.markWriterIndex();
   b.writerIndex(b.writerIndex() - 1);
   b.markWriterIndex();
   assertEquals(a.writerIndex(), b.writerIndex());
   a.writerIndex(a.writerIndex() + 1);
   b.writerIndex(b.writerIndex() + 1);
   assertEquals(a.writerIndex(), b.writerIndex());
   assertTrue(ByteBufUtil.equals(a, b));
   // now discard
   a.discardReadBytes();
   b.discardReadBytes();
   assertEquals(a.readerIndex(), b.readerIndex());
   assertEquals(a.writerIndex(), b.writerIndex());
   assertTrue(ByteBufUtil.equals(a, b));
   a.resetReaderIndex();
   b.resetReaderIndex();
   assertEquals(a.readerIndex(), b.readerIndex());
   a.resetWriterIndex();
   b.resetWriterIndex();
   assertEquals(a.writerIndex(), b.writerIndex());
   assertTrue(ByteBufUtil.equals(a, b));
 }
Пример #2
0
 @Override
 public ByteBuf markWriterIndex() {
   buf.markWriterIndex();
   return this;
 }