/** * Checks the parameter range. * * @param i The integer to check to be in the range of an unsigned byte * integer ({@value SIZE} bits). * @return {@code true} * @throws IllegalArgumentException If {@code i} is less than * {@link #MIN_VALUE} or greater than {@link #MAX_VALUE}. */ public static boolean check(final int i) { return check(i, "Integer out of range", null); } }
final void setRawPlatform(final int platform) { assert UByte.check(platform); this.platform = (byte) platform; setInit(PLATFORM, true); }
public final void setPlatform(final short platform) { final boolean known = UNKNOWN != platform; if (known) { UByte.check(platform, name, "Platform out of range"); this.platform = (byte) platform; } else { this.platform = 0; } setInit(PLATFORM, known); }
@Test public void testCheck() { try { UByte.check(UByte.MIN_VALUE - 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } UByte.check(UByte.MIN_VALUE); UByte.check(UByte.MAX_VALUE); try { UByte.check(UByte.MAX_VALUE + 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } } }