@Test
  public void testTruncate() {
    file.addBlock(new byte[0]);
    file.addBlock(new byte[0]);
    file.addBlock(new byte[0]);
    file.addBlock(new byte[0]);

    assertThat(file.blockCount()).isEqualTo(4);

    file.truncateBlocks(2);

    assertThat(file.blockCount()).isEqualTo(2);
    assertThat(file.getBlock(2)).isNull();
    assertThat(file.getBlock(3)).isNull();
    assertThat(file.getBlock(0)).isNotNull();

    file.truncateBlocks(0);
    assertThat(file.blockCount()).isEqualTo(0);
    assertThat(file.getBlock(0)).isNull();
  }
Tests for the lower-level operations dealing with the blocks of a {@link RegularFile}.

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