@Test
  public void testAllocate() throws IOException {
    HeapDisk disk = new HeapDisk(4, 10, 0);

    disk.allocate(blocks, 1);

    assertThat(blocks.blockCount()).isEqualTo(1);
    assertThat(blocks.getBlock(0).length).isEqualTo(4);
    assertThat(disk.getUnallocatedSpace()).isEqualTo(36);

    disk.allocate(blocks, 5);

    assertThat(blocks.blockCount()).isEqualTo(6);
    for (int i = 0; i < blocks.blockCount(); i++) {
      assertThat(blocks.getBlock(i).length).isEqualTo(4);
    }
    assertThat(disk.getUnallocatedSpace()).isEqualTo(16);
    assertThat(disk.blockCache.blockCount()).isEqualTo(0);
  }
Tests for {@link HeapDisk}.

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