示例#1
0
  private static void assertShort(Slice slice, short index) {
    // fill slice with FF
    slice.fill((byte) 0xFF);

    // set and get the value
    slice.setShort(index, 0xAA55);
    assertEquals(slice.getShort(index), (short) 0xAA55);

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

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

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

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