private static void assertByte(Slice slice, byte index) { // fill slice with FF slice.fill((byte) 0xFF); // set and get unsigned value slice.setByte(index, 0xA5); assertEquals(slice.getUnsignedByte(index), 0x0000_00A5); // set and get the value slice.setByte(index, 0xA5); assertEquals(slice.getByte(index), (byte) 0xA5); try { slice.getByte(-1); fail("expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { } try { slice.getByte((slice.length() - SIZE_OF_BYTE) + 1); fail("expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { } try { slice.getByte(slice.length()); fail("expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { } try { slice.getByte(slice.length() + 1); fail("expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { } }