public void testDefaultAllocation() {
    HandleDataStore hds = new HandleDataStore();
    int i = 1;
    for (; i <= 10000; i++) {
      int handle = hds.allocate();
      assertEquals(i, handle);
    }

    assertEquals(i - 1, hds.size());
    assertEquals(i - 1, hds.last());
    assertEquals(1, hds.first());

    int handle = hds.first();
    assertTrue(hds.isAllocated(handle));
    for (i = 2; i <= 10000; i++) {
      assertEquals(i, handle = hds.next(handle));
      assertTrue(hds.isAllocated(handle));
    }
    assertEquals(0, handle = hds.next(handle));
    assertTrue(!hds.isAllocated(handle));

    handle = hds.last();
    assertTrue(hds.isAllocated(handle));
    for (i = 10000 - 1; i > 0; i--) {
      assertEquals(i, handle = hds.previous(handle));
      assertTrue(hds.isAllocated(handle));
    }
    assertEquals(0, handle = hds.previous(handle));
    assertTrue(!hds.isAllocated(handle));
  }
 private void deallocate(HandleDataStore hds, int handle) {
   hds.deallocate(handle);
   assertTrue(!hds.isAllocated(handle));
 }
 private void allocate(HandleDataStore hds, int handle) {
   assertTrue(hds.allocate(handle) != 0);
   assertTrue(hds.isAllocated(handle));
 }