@Test public void testStream() throws IOException { System.err.println("testStream"); RandomDataInput rdi = new RandomDataInputMemory(new DataInputStream(new ByteArrayInputStream(data)), (long)data.length); doTest(rdi); }
protected void doTest(RandomDataInput rdi) throws IOException { //System.err.println("As stream"); for(byte b : data) { byte got = rdi.readByte(); System.err.println("Got=" + got + " expected " + b); assertEquals(b, got); } rdi.seek(0); for(byte b : data) { byte got = rdi.readByte(); //System.err.println("Got=" + got + " expected " + b); assertEquals(b, got); } for(int i=0;i<data.length;i++) { rdi.seek(i); byte got = rdi.readByte(); //System.err.println("Got=" + got + " expected " + data[i]); assertEquals(data[i], got); } } }
@Test public void testStreamMulti() throws IOException { System.err.println("testStreamMulti"); final int old = RandomDataInputMemory.MAX_INDIVIDUAL_BUFFER_SIZE; for(int l : new int[]{2,3,4,5,6}) { RandomDataInputMemory.MAX_INDIVIDUAL_BUFFER_SIZE = l; RandomDataInput rdi = new RandomDataInputMemory(new DataInputStream(new ByteArrayInputStream(data)), (long)data.length); doTest(rdi); } RandomDataInputMemory.MAX_INDIVIDUAL_BUFFER_SIZE = old; }
@Test public void testSingle() throws IOException { System.err.println("testSingle"); RandomDataInput rdi = new RandomDataInputMemory(data); doTest(rdi); }