@Test
  public void testAllocateFromCache_fullAllocationFromCache() throws IOException {
    HeapDisk disk = new HeapDisk(4, 10, 10);
    disk.allocate(blocks, 10);

    assertThat(disk.getUnallocatedSpace()).isEqualTo(0);

    disk.free(blocks);

    assertThat(blocks.blockCount()).isEqualTo(0);
    assertThat(disk.blockCache.blockCount()).isEqualTo(10);

    List<byte[]> cachedBlocks = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
      cachedBlocks.add(disk.blockCache.getBlock(i));
    }

    disk.allocate(blocks, 6);

    assertThat(blocks.blockCount()).isEqualTo(6);
    assertThat(disk.blockCache.blockCount()).isEqualTo(4);

    // the 6 arrays in blocks are the last 6 arrays that were cached
    for (int i = 0; i < 6; i++) {
      assertThat(blocks.getBlock(i)).isEqualTo(cachedBlocks.get(i + 4));
    }
  }
Tests for {@link HeapDisk}.

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