### Question:
LimitedInputStream extends InputStream { public int read() throws IOException { int result; if (m_limit <= 0) return(-1); result = m_source.read(); if (result >= 0) m_limit--; return(result); } LimitedInputStream(InputStream source); int getLimit(); void setLimit(int length); int read(); int read(byte buffer[], int offset, int length); long skip(long n); int available(); void close();  }### Answer:
@Test(expected = NullPointerException.class) public void readNullBuffer() throws IOException { m_fixture.read(null, 0, 0); }
@Test(expected = IndexOutOfBoundsException.class) public void readNegOffset() throws IOException { m_fixture.read(m_expected, -1, 1); }
@Test(expected = IndexOutOfBoundsException.class) public void readNegLength() throws IOException { m_fixture.read(m_expected, 0, -1); }
@Test(expected = IndexOutOfBoundsException.class) public void readOffsetLengthTooLong() throws IOException { m_fixture.read(m_expected, 5, 6); }
@Test public void readMaxLimit() throws IOException { read(Integer.MAX_VALUE); }
@Test public void readExactLimit() throws IOException { read(m_expected.length); }
@Test public void readShortLimit() throws IOException { read(m_expected.length / 2); }
@Test public void readZeroLimit() throws IOException { read(0); }
@Test public void readBufferZeroLength() throws IOException { assertEquals(0, m_fixture.read(m_expected, 0, 0)); }
@Test public void readBufferZeroLimit() throws IOException { assertEquals(-1, m_fixture.read(m_expected, 0, 1)); }