@Test
public void testReadFully() throws IOException {

  final byte[] input = "this is a sample string to read".getBytes();
  final ByteArrayInputStream inputStream = new ByteArrayInputStream(input);
  final byte[] dst = new byte[50];
  try {
    BsPatch.readFully(inputStream, dst, 0, 50);
    Assert.fail("Should've thrown an IOException");
  } catch (IOException expected) {
    // Pass
  }
  inputStream.reset();
  BsPatch.readFully(inputStream, dst, 0, input.length);
  Assert.assertTrue(regionEquals(dst, 0, input, 0, input.length));
  inputStream.reset();
  BsPatch.readFully(inputStream, dst, 40, 10);
  Assert.assertTrue(regionEquals(dst, 40, input, 0, 10));
  inputStream.reset();
  try {
    BsPatch.readFully(inputStream, dst, 45, 11);
    Assert.fail("Should've thrown an IndexOutOfBoundsException");
  } catch (IndexOutOfBoundsException expected) {
    // Pass
  }
}