Skip to content

Commit

Permalink
Remove useless UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
RongtongJin committed Jan 16, 2024
1 parent 038e832 commit 0e24971
Showing 1 changed file with 0 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,51 +82,4 @@ private static void write(File file, byte[] data) throws IOException {
}
}
}

@Test
public void testUnpooledByteBuffer() {
ByteBuffer buffer = ByteBuffer.allocateDirect(128);
try {
int value = Integer.MAX_VALUE;
for (int i = 0; i < 128 / 4; i++) {
buffer.putInt(value);
}
buffer.flip();
ByteBuf buf1 = Unpooled.wrappedBuffer(buffer);
Assert.assertEquals(buf1.readableBytes(), 128);
Assert.assertEquals(buf1.readerIndex(), 0);
Assert.assertEquals(buf1.writerIndex(), 128);

for (int i = 0; i < 128 / 4; i++) {
Assert.assertEquals(buf1.readInt(), value);
}
} finally {
((DirectBuffer) buffer).cleaner().clean();
}
}

@Test
public void testCompositeByteBuffer() {
ByteBuffer buffer = ByteBuffer.allocateDirect(128);
try {
int value = Integer.MAX_VALUE;
for (int i = 0; i < 128 / 4; i++) {
buffer.putInt(value);
}
buffer.flip();
ByteBuf buf = Unpooled.wrappedBuffer(buffer);
CompositeByteBuf cbuf = ByteBufAllocator.DEFAULT.compositeBuffer();
cbuf.addComponent(true, buf);
Assert.assertEquals(cbuf.readerIndex(), 0);
Assert.assertEquals(cbuf.writerIndex(), 128);
Assert.assertEquals(cbuf.readableBytes(), 128);
Assert.assertEquals(cbuf.refCnt(), 1);
Assert.assertEquals(buf.refCnt(), 1);
cbuf.release();
Assert.assertEquals(cbuf.refCnt(), 0);
Assert.assertEquals(buf.refCnt(), 0);
} finally {
((DirectBuffer) buffer).cleaner().clean();
}
}
}

0 comments on commit 0e24971

Please sign in to comment.