### Question:
BitUtil { public static boolean isPowerOfTwo(final int value) { return value > 0 && ((value & (~value + 1)) == value); } 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 shouldDetectPowersOfTwoForInts() { assertTrue(isPowerOfTwo(1)); assertTrue(isPowerOfTwo(2)); assertTrue(isPowerOfTwo(4)); assertTrue(isPowerOfTwo(32)); assertTrue(isPowerOfTwo(1 << 30)); assertFalse(isPowerOfTwo(Integer.MIN_VALUE)); assertFalse(isPowerOfTwo(0)); assertFalse(isPowerOfTwo(Integer.MIN_VALUE + 1)); assertFalse(isPowerOfTwo(-1)); assertFalse(isPowerOfTwo(3)); assertFalse(isPowerOfTwo(31)); assertFalse(isPowerOfTwo((1 << 30) + 1)); assertFalse(isPowerOfTwo(Integer.MAX_VALUE)); }
@Test void shouldDetectPowersOfTwoForLongs() { assertTrue(isPowerOfTwo(1L)); assertTrue(isPowerOfTwo(2L)); assertTrue(isPowerOfTwo(4L)); assertTrue(isPowerOfTwo(32L)); assertTrue(isPowerOfTwo(1L << 30)); assertTrue(isPowerOfTwo(1L << 31)); assertTrue(isPowerOfTwo(1L << 32)); assertFalse(isPowerOfTwo(Long.MIN_VALUE)); assertFalse(isPowerOfTwo(0L)); assertFalse(isPowerOfTwo(Long.MIN_VALUE + 1)); assertFalse(isPowerOfTwo(-1L)); assertFalse(isPowerOfTwo(3L)); assertFalse(isPowerOfTwo(31L)); assertFalse(isPowerOfTwo((1L << 30L) + 1)); assertFalse(isPowerOfTwo((1L << 31L) + 1)); assertFalse(isPowerOfTwo((1L << 32L) + 1)); assertFalse(isPowerOfTwo(Long.MAX_VALUE)); }