@Test public void testReadResetReadDirectBufferBug() throws IOException { // Make sure we use the exact size of the buffer int size = BufferedImageInputStream.DEFAULT_BUFFER_SIZE; // Fill bytes byte[] bytes = new byte[size * 2]; random.nextBytes(bytes); // Create wrapper stream BufferedImageInputStream stream = new BufferedImageInputStream(new ByteArrayImageInputStream(bytes)); // Read to fill the buffer, then reset stream.readLong(); stream.seek(0); // Read fully and compare byte[] result = new byte[size]; stream.readFully(result); assertTrue(rangeEquals(bytes, 0, result, 0, size)); stream.readFully(result); assertTrue(rangeEquals(bytes, size, result, 0, size)); }
public void testReadResetReadDirectBufferBug() throws IOException { // Make sure we use the exact size of the buffer final int size = BufferedImageInputStream.DEFAULT_BUFFER_SIZE; // Fill bytes byte[] bytes = new byte[size * 2]; mRandom.nextBytes(bytes); // Create wrapper stream BufferedImageInputStream stream = new BufferedImageInputStream(new ByteArrayImageInputStream(bytes)); // Read to fill the buffer, then reset stream.readLong(); stream.seek(0); // Read fully and compare byte[] result = new byte[size]; stream.readFully(result); assertTrue(rangeEquals(bytes, 0, result, 0, size)); stream.readFully(result); assertTrue(rangeEquals(bytes, size, result, 0, size)); }
public void testReadResetReadDirectBufferBug() throws IOException { // Make sure we use the exact size of the buffer final int size = BufferedImageInputStream.DEFAULT_BUFFER_SIZE; // Fill bytes byte[] bytes = new byte[size * 2]; random.nextBytes(bytes); // Create wrapper stream BufferedImageInputStream stream = new BufferedImageInputStream(new ByteArrayImageInputStream(bytes)); // Read to fill the buffer, then reset stream.readLong(); stream.seek(0); // Read fully and compare byte[] result = new byte[size]; stream.readFully(result); assertTrue(rangeEquals(bytes, 0, result, 0, size)); stream.readFully(result); assertTrue(rangeEquals(bytes, size, result, 0, size)); }