GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ZstdEncoder not producing data when source is smaller than block size · Issue #15340 · netty/netty Closed Milestone DescriptionIf the size of the input buffer is smaller than the configured block size (64 KB by default), then The actual size should be around 25 bytes. $ echo -n 'Hello, World'|zstd -v|hexdump -C *** Zstandard CLI (64-bit) v1.5.5, by Yann Collet *** /*stdin*\ :208.33% ( 12 B => 25 B, /*stdout*\) 00000000 28 b5 2f fd 04 58 61 00 00 48 65 6c 6c 6f 2c 20 |(./..Xa..Hello, | 00000010 57 6f 72 6c 64 51 c7 d3 f2 |WorldQ...| 00000019 Of the following tests, only the first test is successful. import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.VoidChannelPromise; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.codec.compression.ZstdEncoder; import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) class ZstdEncoderTest { static String TEST_CONTENT = "Hello, World"; @Mock private ChannelHandlerContext ctx; @BeforeEach public void setup() { when(ctx.alloc()).thenReturn(ByteBufAllocator.DEFAULT); } @Test void testEncodeWithSmallBlockSize() throws Exception { int length = TEST_CONTENT.getBytes(StandardCharsets.UTF_8).length; // block size <= size of TEST_CONTENT testEncoder(new ZstdEncoder(length, 1024)); } @Test void testEncodeWithLargerBlockSize() throws Exception { int length = TEST_CONTENT.getBytes(StandardCharsets.UTF_8).length; // block size > size of TEST_CONTENT testEncoder(new ZstdEncoder(length + 1, 1024)); } @Test void testEncodeWithDefaults() throws Exception { // default block size of 64kb testEncoder(new ZstdEncoder()); } void testEncoder(ZstdEncoder encoder) throws Exception { var in = Unpooled.copiedBuffer(TEST_CONTENT, StandardCharsets.UTF_8); var chan = new EmbeddedChannel(); encoder.handlerAdded(ctx); var promise = new VoidChannelPromise(chan, true); encoder.write(ctx, in, promise); var outCaptor = ArgumentCaptor.forClass(ByteBuf.class); verify(ctx).write(outCaptor.capture(), eq(promise)); var out = outCaptor.getValue(); assertThat(out.readableBytes()).isPositive(); out.release(); } } Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |