Exemple #1
0
  private static void assertDouble(Slice slice, int index) {
    // fill slice with FF
    slice.fill((byte) 0xFF);

    // set and get the value
    slice.setDouble(index, longBitsToDouble(0xAAAA_AAAA_5555_5555L));
    assertEquals(doubleToLongBits(slice.getDouble(index)), 0xAAAA_AAAA_5555_5555L);

    try {
      slice.getDouble(-1);
      fail("expected IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException e) {
    }

    try {
      slice.getDouble((slice.length() - SIZE_OF_DOUBLE) + 1);
      fail("expected IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException e) {
    }

    try {
      slice.getDouble(slice.length());
      fail("expected IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException e) {
    }

    try {
      slice.getDouble(slice.length() + 1);
      fail("expected IndexOutOfBoundsException");
    } catch (IndexOutOfBoundsException e) {
    }
  }