Skip to content

Commit

Permalink
Add a test for a stream of skippable frame only
Browse files Browse the repository at this point in the history
  • Loading branch information
odaira committed Jul 27, 2020
1 parent d5db0f0 commit a1594ed
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/net/jpountz/lz4/LZ4FrameIOStreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,27 @@ public void testInputOutputSkipped() throws IOException {
}
}

@Test
public void testSkippableOnly() throws IOException {
final File lz4File = Files.createTempFile("lz4test", ".lz4").toFile();
try {
try (FileOutputStream fos = new FileOutputStream(lz4File)) {
final int skipSize = 1 << 10;
final ByteBuffer skipBuffer = ByteBuffer.allocate(skipSize + 8).order(ByteOrder.LITTLE_ENDIAN);
skipBuffer.putInt(LZ4FrameInputStream.MAGIC_SKIPPABLE_BASE | 0x00000007); // anything 00 through FF should work
skipBuffer.putInt(skipSize);
final byte[] skipRandom = new byte[skipSize];
new Random(478278L).nextBytes(skipRandom);
skipBuffer.put(skipRandom);
fos.write(skipBuffer.array());
}
try (InputStream is = new LZ4FrameInputStream(new FileInputStream(lz4File))) {
Assert.assertEquals(-1, is.read());
}
} finally {
lz4File.delete();
}
}

@Test
public void testStreamWithContentSize() throws IOException {
Expand Down

0 comments on commit a1594ed

Please sign in to comment.