Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/test/java/org/apache/commons/io/IOUtilsTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1493,4 +1493,32 @@ public void close() throws IOException { }
assertSame(bw, IOUtils.buffer(bw));
assertSame(bw, IOUtils.buffer(bw, 1024));
}


@Test
public void testCopyLarge_SkipWithInvalidOffset() throws IOException {
ByteArrayInputStream is = null;
ByteArrayOutputStream os = null;
try {
// Create streams
is = new ByteArrayInputStream(iarr);
os = new ByteArrayOutputStream();

// Test our copy method
assertEquals(100, IOUtils.copyLarge(is, os, -10, 100));
final byte[] oarr = os.toByteArray();

// check that output length is correct
assertEquals(100, oarr.length);
// check that output data corresponds to input data
assertEquals(1, oarr[1]);
assertEquals(79, oarr[79]);
assertEquals(-1, oarr[80]);

} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(os);
}
}

}