@Test
public void testWorksIfStreamIsGnawed() throws IOException {

    BufferedReader originalReader =
            new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/leaves-of-grass.txt")));
    InputStream stream = getClass().getResourceAsStream("/leaves-of-grass.txt");
    byte[] buf = new byte[100000];
    int read = stream.read(buf, 0, 99999);
    GnawedInputStream gnawedInputStream = new GnawedInputStream(buf, read, stream);
    BufferedReader testReader = new BufferedReader(new InputStreamReader(gnawedInputStream));
    String originalLine;
    while ((originalLine = originalReader.readLine()) != null) {
        Assert.assertEquals(originalLine, testReader.readLine());
    }
    Assert.assertEquals(null, testReader.readLine());
}