/**
* @tests java.util.zip.InflaterInputStream#skip(long)
*/
public void test_skipJ() throws IOException {
InputStream is = Support_Resources.getStream("hyts_available.tst");
InflaterInputStream iis = new InflaterInputStream(is);
// Tests for skipping a negative number of bytes.
try {
iis.skip(-3);
fail("IllegalArgumentException not thrown");
} catch (IllegalArgumentException e) {
// Expected
}
assertEquals("Incorrect Byte Returned.", 5, iis.read());
try {
iis.skip(Integer.MIN_VALUE);
fail("IllegalArgumentException not thrown");
} catch (IllegalArgumentException e) {
// Expected
}
assertEquals("Incorrect Byte Returned.", 4, iis.read());
// Test to make sure the correct number of bytes were skipped
assertEquals("Incorrect Number Of Bytes Skipped.", 3, iis.skip(3));
// Test to see if the number of bytes skipped returned is true.
assertEquals("Incorrect Byte Returned.", 7, iis.read());
assertEquals("Incorrect Number Of Bytes Skipped.", 0, iis.skip(0));
assertEquals("Incorrect Byte Returned.", 0, iis.read());
// Test for skipping more bytes than available in the stream
assertEquals("Incorrect Number Of Bytes Skipped.", 2, iis.skip(4));
assertEquals("Incorrect Byte Returned.", -1, iis.read());
iis.close();
}