### Question:
Pow2 { public static int roundToPowerOfTwo(final int value) { if (value > MAX_POW2) { throw new IllegalArgumentException("There is no larger power of 2 int for value:"+value+" since it exceeds 2^31."); } if (value < 0) { throw new IllegalArgumentException("Given value:"+value+". Expecting value >= 0."); } final int nextPow2 = 1 << (32 - Integer.numberOfLeadingZeros(value - 1)); return nextPow2; }  static int roundToPowerOfTwo(final int value); static boolean isPowerOfTwo(final int value); static long align(final long value, final int alignment); static final int MAX_POW2; }### Answer:
@Test public void testRound() { assertEquals(4, Pow2.roundToPowerOfTwo(4)); assertEquals(4, Pow2.roundToPowerOfTwo(3)); assertEquals(1, Pow2.roundToPowerOfTwo(0)); assertEquals(MAX_POSITIVE_POW2, Pow2.roundToPowerOfTwo(MAX_POSITIVE_POW2)); }
@Test(expected = IllegalArgumentException.class) public void testMaxRoundException() { Pow2.roundToPowerOfTwo(MAX_POSITIVE_POW2 + 1); fail(); }
@Test(expected = IllegalArgumentException.class) public void testNegativeRoundException() { Pow2.roundToPowerOfTwo(-1); fail(); }