@Test
public void testWriteTo() throws IOException, InterruptedException {

  FSInputStream fsin = new MockFSInputStream();
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  // new int[]{s_1, c_1, s_2, c_2, ..., s_n, c_n} means to test
  // reading c_i bytes starting at s_i
  int[] pairs = new int[]{ 0, 10000,
                           50, 100,
                           50, 6000,
                           1000, 2000,
                           0, 1,
                           0, 0,
                           5000, 0,
                          };
                          
  assertTrue("Pairs array must be even", pairs.length % 2 == 0);
  
  for (int i = 0; i < pairs.length; i+=2) {
    StreamFile.copyFromOffset(fsin, os, pairs[i], pairs[i+1]);
    assertArrayEquals("Reading " + pairs[i+1]
                      + " bytes from offset " + pairs[i],
                      getOutputArray(pairs[i], pairs[i+1]),
                      os.toByteArray());
    os.reset();
  }
  
}