ReverseBinaryNumber { public int reverse(int input) { int result = 1; do { result <<= 1; result |= (input & 1) == 1 ? 0 : 1; input >>= 1; } while (input != 0); result = reverseBitsOrder(result); result = removeFirstOne(result); return result; } ReverseBinaryNumber(); int reverse(int input);  }
@Test public void shouldReturnOneIfInputIsZero() { int input = 0; int result = reverseBinaryNumber.reverse(input); assertEquals(1, result); }
@Test public void shouldReturnZeroIfInputIsOne() { int input = 1; int result = reverseBinaryNumber.reverse(input); assertEquals(0, result); }
@Test public void shouldReturnZeroIfInputIsFullOfOnes() { int input = 63; int result = reverseBinaryNumber.reverse(input); assertEquals(0, result); }
@Test public void shouldReturnOneIfInputIsTwo() { int input = 2; int result = reverseBinaryNumber.reverse(input); assertEquals(1, result); }
@Test public void shouldReturnTheReverseBinaryNumber() { int input = 11; int result = reverseBinaryNumber.reverse(input); assertEquals(4, result); }