### Question:
BitUtil { public static int nextHighestPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; } private  BitUtil(); static boolean isPowerOfTwo(final int value); static boolean isPowerOfTwo(final long value); static int previousPowerOfTwo(int v); static long previousPowerOfTwo(long v); static int nearbyPowerOfTwo(int x); static long nearbyPowerOfTwo(long x); static int nextHighestPowerOfTwo(int v); static long nextHighestPowerOfTwo(long v); static long align(long value, int alignment); static long ceilDiv(long dividend, long divisor); static int ceilDiv(int dividend, int divisor);  }### Answer:
@Test void shouldReturnNextPowerOfTwoForInts() { assertEquals(Integer.MIN_VALUE, nextHighestPowerOfTwo(Integer.MIN_VALUE)); assertEquals(0, nextHighestPowerOfTwo(Integer.MIN_VALUE + 1)); assertEquals(0, nextHighestPowerOfTwo(-1)); assertEquals(0, nextHighestPowerOfTwo(0)); assertEquals(1, nextHighestPowerOfTwo(1)); assertEquals(2, nextHighestPowerOfTwo(2)); assertEquals(4, nextHighestPowerOfTwo(3)); assertEquals(4, nextHighestPowerOfTwo(4)); assertEquals(32, nextHighestPowerOfTwo(31)); assertEquals(32, nextHighestPowerOfTwo(32)); assertEquals(1 << 30, nextHighestPowerOfTwo(1 << 30)); assertEquals(Integer.MIN_VALUE, nextHighestPowerOfTwo((1 << 30) + 1)); assertEquals(Integer.MIN_VALUE, nextHighestPowerOfTwo(Integer.MAX_VALUE - 1)); assertEquals(Integer.MIN_VALUE, nextHighestPowerOfTwo(Integer.MAX_VALUE)); }
@Test void shouldReturnNextPowerOfTwoForLongs() { assertEquals(Long.MIN_VALUE, nextHighestPowerOfTwo(Long.MIN_VALUE)); assertEquals(0L, nextHighestPowerOfTwo(Long.MIN_VALUE + 1L)); assertEquals(0L, nextHighestPowerOfTwo(-1L)); assertEquals(0L, nextHighestPowerOfTwo(0L)); assertEquals(2L, nextHighestPowerOfTwo(2L)); assertEquals(4L, nextHighestPowerOfTwo(3L)); assertEquals(1L, nextHighestPowerOfTwo(1L)); assertEquals(4L, nextHighestPowerOfTwo(4L)); assertEquals(32L, nextHighestPowerOfTwo(31L)); assertEquals(32L, nextHighestPowerOfTwo(32L)); assertEquals(1L << 62, nextHighestPowerOfTwo(1L << 62)); assertEquals(Long.MIN_VALUE, nextHighestPowerOfTwo((1L << 62) + 1)); assertEquals(Long.MIN_VALUE, nextHighestPowerOfTwo(Long.MAX_VALUE - 1)); assertEquals(Long.MIN_VALUE, nextHighestPowerOfTwo(Long.MAX_VALUE)); }