### Question:
BitUtil { public static int previousPowerOfTwo(int v) { v |= (v >> 1); v |= (v >> 2); v |= (v >> 4); v |= (v >> 8); v |= (v >> 16); return v - (v >>> 1); } 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 shouldReturnPreviousPowerOfTwoForInts() { assertEquals(Integer.MIN_VALUE, previousPowerOfTwo(Integer.MIN_VALUE)); assertEquals(Integer.MIN_VALUE, previousPowerOfTwo(Integer.MIN_VALUE + 1)); assertEquals(Integer.MIN_VALUE, previousPowerOfTwo(-1)); assertEquals(0, previousPowerOfTwo(0)); assertEquals(1, previousPowerOfTwo(1)); assertEquals(2, previousPowerOfTwo(2)); assertEquals(2, previousPowerOfTwo(3)); assertEquals(4, previousPowerOfTwo(4)); assertEquals(16, previousPowerOfTwo(31)); assertEquals(32, previousPowerOfTwo(32)); assertEquals(1 << 30, previousPowerOfTwo(1 << 30)); assertEquals(1 << 30, previousPowerOfTwo((1 << 30) + 1)); assertEquals(1 << 30, previousPowerOfTwo(Integer.MAX_VALUE - 1)); assertEquals(1 << 30, previousPowerOfTwo(Integer.MAX_VALUE)); }
@Test void shouldReturnPreviousPowerOfTwoForLongs() { assertEquals(Long.MIN_VALUE, previousPowerOfTwo(Long.MIN_VALUE)); assertEquals(Long.MIN_VALUE, previousPowerOfTwo(Long.MIN_VALUE + 1)); assertEquals(Long.MIN_VALUE, previousPowerOfTwo(-1L)); assertEquals(0L, previousPowerOfTwo(0L)); assertEquals(1L, previousPowerOfTwo(1L)); assertEquals(2L, previousPowerOfTwo(2L)); assertEquals(2L, previousPowerOfTwo(3L)); assertEquals(4L, previousPowerOfTwo(4L)); assertEquals(32L, previousPowerOfTwo(32)); assertEquals(16L, previousPowerOfTwo(31L)); assertEquals(1L << 62, previousPowerOfTwo(1L << 62)); assertEquals(1L << 62, previousPowerOfTwo((1L << 62) + 1)); assertEquals(1L << 62, previousPowerOfTwo(Long.MAX_VALUE - 1)); assertEquals(1L << 62, previousPowerOfTwo(Long.MAX_VALUE)); }