Skip to content
Permalink
Browse files
Sort members.
  • Loading branch information
garydgregory committed May 5, 2022
1 parent 91217d2 commit 51c68bef1dd80530b52ee115b85955a743bf63ff
Showing 1 changed file with 21 additions and 21 deletions.
@@ -31,6 +31,27 @@

public class CpioArchiveInputStreamTest extends AbstractTestCase {

@Test
public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
final byte[] buf = new byte[2];
try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
final ArchiveEntry e = archive.getNextEntry();
IOUtils.toByteArray(archive);
assertEquals(-1, archive.read(buf));
assertEquals(-1, archive.read(buf));
}
}

@Test
public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
final ArchiveEntry e = archive.getNextEntry();
IOUtils.toByteArray(archive);
assertEquals(-1, archive.read());
assertEquals(-1, archive.read());
}
}

@Test
public void testCpioUnarchive() throws Exception {
final StringBuilder expected = new StringBuilder();
@@ -83,25 +104,4 @@ public void testCpioUnarchiveMultibyteCharName() throws Exception {
assertEquals(2, count);
}

@Test
public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
final ArchiveEntry e = archive.getNextEntry();
IOUtils.toByteArray(archive);
assertEquals(-1, archive.read());
assertEquals(-1, archive.read());
}
}

@Test
public void multiByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
final byte[] buf = new byte[2];
try (InputStream in = Files.newInputStream(getFile("bla.cpio").toPath()); CpioArchiveInputStream archive = new CpioArchiveInputStream(in)) {
final ArchiveEntry e = archive.getNextEntry();
IOUtils.toByteArray(archive);
assertEquals(-1, archive.read(buf));
assertEquals(-1, archive.read(buf));
}
}

}

0 comments on commit 51c68be

Please sign in to comment.