@Test
  public void testTruncate() throws IOException {
    RegularFile file = regularFile(10);
    FileChannel channel = channel(file, WRITE);

    channel.truncate(10); // no resize, >= size
    assertEquals(10, file.size());
    channel.truncate(11); // no resize, > size
    assertEquals(10, file.size());
    channel.truncate(5); // resize down to 5
    assertEquals(5, file.size());

    channel.position(20);
    channel.truncate(10);
    assertEquals(10, channel.position());
    channel.truncate(2);
    assertEquals(2, channel.position());
  }
Most of the behavior of {@link JimfsFileChannel} is handled by the {@link RegularFile}
implementations, so the thorough tests of that are in {@link RegularFileTest}. This mostly tests
interactions with the file and channel positions.

@author Colin Decker
jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java