コード例 #1
0
  @Test
  public void testRemove() throws Exception {
    final long key1 = randomKey();
    final long key2 = randomKey();
    hsa.ensure(key1, key2);

    assertTrue(hsa.remove(key1, key2));
    assertFalse(hsa.remove(key1, key2));
  }
コード例 #2
0
  @Test
  public void testPutRemoveGetMany() {
    final long factor = 123456;
    final int k = 5000;
    final int mod = 100;

    for (int i = 1; i <= k; i++) {
      long key1 = (long) i;
      long key2 = key1 * factor;
      assertTrue(hsa.ensure(key1, key2) > 0);
    }

    for (int i = mod; i <= k; i += mod) {
      long key1 = (long) i;
      long key2 = key1 * factor;
      assertTrue(hsa.remove(key1, key2));
    }

    for (int i = 1; i <= k; i++) {
      long key1 = (long) i;
      long key2 = key1 * factor;
      long valueAddress = hsa.get(key1, key2);

      if (i % mod == 0) {
        assertEquals(NULL_ADDRESS, valueAddress);
      } else {
        assertNotEquals(NULL_ADDRESS, valueAddress);
      }
    }
  }
コード例 #3
0
  @Test
  public void testSize() throws Exception {
    final long key1 = randomKey();
    final long key2 = randomKey();

    hsa.ensure(key1, key2);
    assertEquals(1, hsa.size());

    assertTrue(hsa.remove(key1, key2));
    assertEquals(0, hsa.size());
  }
コード例 #4
0
 @Test(expected = AssertionError.class)
 @RequireAssertEnabled
 public void testRemove_whenDisposed() throws Exception {
   hsa.dispose();
   hsa.remove(1, 1);
 }