I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 1b5309be authored by zzz's avatar zzz
Browse files

junit test for new DataHelper.skip()

parent d2a1025b
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ package net.i2p.data;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
......@@ -126,4 +127,29 @@ public class DataHelperTest extends TestCase{
}
}
public void testSkip() throws Exception {
final int sz = 256;
TestInputStream tis = new TestInputStream(sz);
DataHelper.skip(tis, sz);
try {
DataHelper.skip(tis, 1);
fail();
} catch (IOException ioe) {}
}
private static class TestInputStream extends ByteArrayInputStream {
private final Random r = new Random();
public TestInputStream(int size) {
super(new byte[size]);
r.nextBytes(buf);
}
/** skip a little at a time, or sometimes zero */
@Override
public long skip(long n) {
return super.skip(Math.min(n, r.nextInt(4)));
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment