@Test public void testZeroOffsetAndMaximalLength() { ByteBufferInputStream stream = createStream(); byte[] read = new byte[32]; stream.read(read, 0, 32); for (int i = 0; i < read.length; i++) { Assert.assertThat(read[i], is((byte) i)); } }
@Test public void testZeroOffsetAndZeroLength() { ByteBufferInputStream stream = createStream(); byte[] read = new byte[32]; stream.read(read, 0, 0); for (int i = 0; i < read.length; i++) { Assert.assertThat(read[i], is((byte) 0)); } }
@Test public void testMaximalOffsetAndZeroLength() { ByteBufferInputStream stream = createStream(); byte[] read = new byte[32]; stream.read(read, 32, 0); for (int i = 0; i < read.length; i++) { Assert.assertThat(read[i], is((byte) 0)); } }
@Test public void testNullReadArray() { ByteBufferInputStream stream = createStream(); try { stream.read(null, 0, 0); fail("Expected NullPointerException"); } catch (NullPointerException e) { //expected } }
@Test public void testNegativeOffsetAndZeroLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], -1, 0); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testMaximalOffsetAndFiniteLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 32, 4); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testNegativeOffsetAndMaxLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], -1, Integer.MAX_VALUE); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testZeroOffsetAndExcessiveLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 0, 33); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testExcessiveOffsetAndLegalLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 33, 4); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testReasonableSkipValue() throws IOException { ByteBufferInputStream stream = createStream(); assertThat(stream.skip(32), is(32L)); assertThat(stream.read(), is(32)); }
@Test public void testNegativeOffsetAndLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], -1, -1); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testMaxOffsetAndMaxLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], Integer.MAX_VALUE, Integer.MAX_VALUE); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testMinOffsetAndUnitLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], Integer.MIN_VALUE, 1); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testUnitOffsetAndMinLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 1, Integer.MIN_VALUE); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testZeroSkipValue() throws IOException { ByteBufferInputStream stream = createStream(); assertThat(stream.skip(0), is(0L)); assertThat(stream.read(), is(0)); }
@Test public void testZeroOffsetAndNegativeLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 0, -1); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testExcessiveOffsetAndZeroLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 33, 0); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testUnitOffsetAndMaxLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 1, Integer.MAX_VALUE); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testMinOffsetAndNegativeLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], Integer.MIN_VALUE, -1); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testNegativeSkipValue() throws IOException { ByteBufferInputStream stream = createStream(); assertThat(stream.skip(-1), is(0L)); assertThat(stream.read(), is(0)); }