### Question:
LEB128 { public static int decode32u(BinaryReader reader) throws IOException { long tmp = decode(reader, false); if (tmp < 0 || tmp > Integer.MAX_VALUE) { throw new IOException("LEB128 value out of range for java 32 bit unsigned int: " + Long.toUnsignedString(tmp)); } return (int) tmp; }  static int decode32s(BinaryReader reader); static int decode32u(BinaryReader reader); static long decode(BinaryReader reader, boolean isSigned); static long decode(byte[] bytes, boolean isSigned); static long decode(byte[] bytes, int offset, boolean isSigned);  }### Answer:
@Test public void testUint32Max() throws IOException { int value = LEB128.decode32u(br((byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x07)); Assert.assertEquals(Integer.MAX_VALUE, value); }
@Test public void testUint32Overflow() throws IOException { try { int value = LEB128.decode32u( br((byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x0f)); Assert.fail( "Should not be able to read a LEB128 that is larger than what can fit in java 32 bit int: " + Integer.toUnsignedString(value)); } catch (IOException ioe) { } }