mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-05-01 00:00:02 -04:00
Added test for BufferedIIS. Still some issues with direct reading.
This commit is contained in:
Executable → Regular
+32
-3
@@ -17,14 +17,14 @@ import java.util.Random;
|
||||
* @author last modified by $Author: haraldk$
|
||||
* @version $Id: BufferedImageInputStreamTestCase.java,v 1.0 Jun 30, 2008 3:07:42 PM haraldk Exp$
|
||||
*/
|
||||
public class BufferedImageInputStreamTestCase extends TestCase{
|
||||
public class BufferedImageInputStreamTestCase extends TestCase {
|
||||
protected final Random mRandom = new Random();
|
||||
|
||||
public void testCreate() {
|
||||
public void testCreate() throws IOException {
|
||||
new BufferedImageInputStream(new ByteArrayImageInputStream(new byte[0]));
|
||||
}
|
||||
|
||||
public void testCreateNull() {
|
||||
public void testCreateNull() throws IOException {
|
||||
try {
|
||||
new BufferedImageInputStream(null);
|
||||
fail("Expected IllegalArgumentException");
|
||||
@@ -76,6 +76,35 @@ public class BufferedImageInputStreamTestCase extends TestCase{
|
||||
assertTrue(rangeEquals(bytes, size, result, 0, size));
|
||||
}
|
||||
|
||||
public void testBufferPositionCorrect() throws IOException {
|
||||
// Fill bytes
|
||||
byte[] bytes = new byte[1024];
|
||||
mRandom.nextBytes(bytes);
|
||||
|
||||
ByteArrayImageInputStream input = new ByteArrayImageInputStream(bytes);
|
||||
|
||||
input.readByte();
|
||||
input.readByte();
|
||||
input.skipBytes(124);
|
||||
input.readByte();
|
||||
input.readByte();
|
||||
|
||||
// Sanity check
|
||||
assertEquals(128, input.getStreamPosition());
|
||||
|
||||
BufferedImageInputStream stream = new BufferedImageInputStream(input);
|
||||
|
||||
assertEquals(input.getStreamPosition(), stream.getStreamPosition());
|
||||
|
||||
stream.skipBytes(128);
|
||||
|
||||
//assertTrue(256 <= input.getStreamPosition());
|
||||
assertEquals(256, stream.getStreamPosition());
|
||||
|
||||
stream.seek(1020);
|
||||
assertEquals(1020, stream.getStreamPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test two arrays for range equality. That is, they contain the same elements for some specified range.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user