public void testCreate() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(11), 7); assertEquals(0, stream.getStreamPosition()); assertEquals(7, stream.length()); }
public void testSeekNegative() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); try { stream.seek(-2); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { } assertEquals(0, stream.getStreamPosition()); }
public void testCreateNegativeLength() throws IOException { try { new SubImageInputStream(createStream(0), -1); fail("Expected IllegalArgumentException with negative length"); } catch (IllegalArgumentException e) { } }
public void testReadResetRead() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(32), 16); stream.mark(); byte[] first = new byte[16]; stream.readFully(first); stream.reset(); byte[] second = new byte[16]; stream.readFully(second); assertTrue(Arrays.equals(first, second)); }
public void testCreateNullStream() throws IOException { try { new SubImageInputStream(null, 1); fail("Expected IllegalArgumentException with null stream"); } catch (IllegalArgumentException e) { } }
public void testWrapUnknownLength() throws IOException { SubImageInputStream stream = new SubImageInputStream(new ImageInputStreamImpl() { @Override public int read() throws IOException { throw new UnsupportedOperationException("Method read not implemented"); } @Override public int read(byte[] b, int off, int len) throws IOException { throw new UnsupportedOperationException("Method read not implemented"); } @Override public long length() { return -1; } }, 6); assertEquals(-1, stream.length()); }
public void testCreateNegativeLength() throws IOException { try { new SubImageInputStream(createStream(0), -1); fail("Expected IllegalArgumentException with negative length"); } catch (IllegalArgumentException e) { } }
public void testReadResetRead() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(32), 16); stream.mark(); byte[] first = new byte[16]; stream.readFully(first); stream.reset(); byte[] second = new byte[16]; stream.readFully(second); assertTrue(Arrays.equals(first, second)); }
public void testCreateNullStream() throws IOException { try { new SubImageInputStream(null, 1); fail("Expected IllegalArgumentException with null stream"); } catch (IllegalArgumentException e) { } }
public void testWrapUnknownLength() throws IOException { SubImageInputStream stream = new SubImageInputStream(new ImageInputStreamImpl() { @Override public int read() throws IOException { throw new UnsupportedOperationException("Method read not implemented"); } @Override public int read(byte[] b, int off, int len) throws IOException { throw new UnsupportedOperationException("Method read not implemented"); } @Override public long length() { return -1; } }, 6); assertEquals(-1, stream.length()); }
public void testCreate() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(11), 7); assertEquals(0, stream.getStreamPosition()); assertEquals(7, stream.length()); }
public void testSeekNegative() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); try { stream.seek(-2); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { } assertEquals(0, stream.getStreamPosition()); }
public void testWraphBeyondWrappedLength() throws IOException { SubImageInputStream stream = new SubImageInputStream(createStream(5), 6); assertEquals(5, stream.length()); }
public void testSeekBeforeFlushedPos() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); stream.seek(3); stream.flushBefore(3); assertEquals(3, stream.getStreamPosition()); try { stream.seek(0); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { } assertEquals(3, stream.getStreamPosition()); }
public void testWraphBeyondWrappedLength() throws IOException { SubImageInputStream stream = new SubImageInputStream(createStream(5), 6); assertEquals(5, stream.length()); }
public void testSeekBeforeFlushedPos() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); stream.seek(3); stream.flushBefore(3); assertEquals(3, stream.getStreamPosition()); try { stream.seek(0); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException expected) { } assertEquals(3, stream.getStreamPosition()); }
public void testSeekAfterEOF() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); stream.seek(6); assertEquals(-1, stream.read()); }
public void testSeekAfterEOF() throws IOException { ImageInputStream stream = new SubImageInputStream(createStream(7), 5); stream.seek(6); assertEquals(-1, stream.read()); }
public void testRead() throws IOException { ImageInputStream wrapped = createStream(42); wrapped.skipBytes(13); ImageInputStream stream = new SubImageInputStream(wrapped, 27); assertEquals(0, stream.getStreamPosition()); assertEquals(27, stream.length()); stream.read(); assertEquals(1, stream.getStreamPosition()); assertEquals(27, stream.length()); stream.readFully(new byte[11]); assertEquals(12, stream.getStreamPosition()); assertEquals(27, stream.length()); assertEquals(25, wrapped.getStreamPosition()); }
public void testRead() throws IOException { ImageInputStream wrapped = createStream(42); wrapped.skipBytes(13); ImageInputStream stream = new SubImageInputStream(wrapped, 27); assertEquals(0, stream.getStreamPosition()); assertEquals(27, stream.length()); stream.read(); assertEquals(1, stream.getStreamPosition()); assertEquals(27, stream.length()); stream.readFully(new byte[11]); assertEquals(12, stream.getStreamPosition()); assertEquals(27, stream.length()); assertEquals(25, wrapped.getStreamPosition()); }