### Question:
B2InputStreamExcerpt extends InputStream { @Override public int available() throws IOException { startIfNeeded(); if (atEnd()) { return 0; } return Math.min(getRemaining(), inputStream.available()); } B2InputStreamExcerpt(InputStream inputStream,
                                long start,
                                long length); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b,
                    int off,
                    int len); @Override long skip(long n); @Override int available(); @Override void close(); long getExcerptStart(); long getExcerptLength();  }### Answer:
@Test public void testEmptyExcerpt_available() throws IOException { assertEquals(0, excerpt(makeEmpty(), 0, 0).available()); assertEquals(0, excerpt(makeDigits(), 0, 0).available()); assertEquals(0, excerpt(makeEmpty(), 0, 6).available()); assertEquals(0, excerpt(makeDigits(), 10, 6).available()); assertEquals(0, excerpt(makeEmpty(), 1, 0).available());; assertEquals(0, excerpt(makeDigits(), 10, 0).available());; }
@Test public void testNonEmptyExcerpt_available() throws IOException { assertEquals(3, excerpt(makeDigits(), 6, 3).available()); assertEquals(4, excerpt(makeDigits(), 6, 6).available()); }