コード例 #1
0
  @Test
  public void testCursor_withManyValues() {
    final long factor = 123456;
    final int k = 1000;

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

    boolean[] verifyKeys = new boolean[k];
    Arrays.fill(verifyKeys, false);

    HashSlotCursor16byteKey cursor = hsa.cursor();
    while (cursor.advance()) {
      long key1 = cursor.key1();
      long key2 = cursor.key2();

      assertEquals(key1 * factor, key2);
      verifyKeys[((int) key1) - 1] = true;
    }

    for (int i = 0; i < k; i++) {
      assertTrue("Haven't read " + k + "th key!", verifyKeys[i]);
    }
  }
コード例 #2
0
 @Test(expected = AssertionError.class)
 @RequireAssertEnabled
 public void testCursor_valueAddress_whenDisposed() {
   HashSlotCursor16byteKey cursor = hsa.cursor();
   hsa.dispose();
   cursor.valueAddress();
 }
コード例 #3
0
  @Test
  public void testCursor_valueAddress() {
    final long valueAddress = hsa.ensure(randomKey(), randomKey());

    HashSlotCursor16byteKey cursor = hsa.cursor();
    cursor.advance();
    assertEquals(valueAddress, cursor.valueAddress());
  }
コード例 #4
0
  @Test
  public void testCursor_advance() {
    hsa.ensure(randomKey(), randomKey());

    HashSlotCursor16byteKey cursor = hsa.cursor();
    assertTrue(cursor.advance());
    assertFalse(cursor.advance());
  }
コード例 #5
0
  @Test
  public void testCursor_key2() {
    final long key1 = randomKey();
    final long key2 = randomKey();
    hsa.ensure(key1, key2);

    HashSlotCursor16byteKey cursor = hsa.cursor();
    cursor.advance();
    assertEquals(key2, cursor.key2());
  }
コード例 #6
0
  @Test
  public void testCursor_advance_afterAdvanceReturnsFalse() {
    hsa.ensure(randomKey(), randomKey());

    HashSlotCursor16byteKey cursor = hsa.cursor();
    cursor.advance();
    cursor.advance();

    try {
      cursor.advance();
      fail("cursor.advance() returned false, but subsequent call did not throw AssertionError");
    } catch (AssertionError ignored) {
    }
  }
コード例 #7
0
 @Test
 public void testCursor_advance_whenEmpty() {
   HashSlotCursor16byteKey cursor = hsa.cursor();
   assertFalse(cursor.advance());
 }
コード例 #8
0
 @Test(expected = AssertionError.class)
 @RequireAssertEnabled
 public void testCursor_valueAddress_withoutAdvance() {
   HashSlotCursor16byteKey cursor = hsa.cursor();
   cursor.valueAddress();
 }