### Question:
BitReader { public long bits2SInt(int nb) throws IOException { long result = bits2UInt(nb); if (getBit(result, nb)) { result = setBit(result, nb, false); result = ~result & LONG_BITMASK; result = result + 1; } return result; } BitReader(byte[] test);  BitReader(RandomAccessFile raf, long startPos); void incrByte(); void setBitOffset(int bitOffset); long getPos(); long bits2UInt(int nb); long bits2SInt(int nb);  }### Answer:
@Test public void testSignedPositive() throws IOException { BitReader bu = new BitReader(new byte[] {32, 0, 0, 0}); assertEquals(2, (int) bu.bits2SInt(4)); }
@Test public void testSignedNegative() throws IOException { BitReader bu = new BitReader(new byte[] {(byte) 160, 0, 0, 0}); int binary = (int) bu.bits2SInt(4); assertEquals(-2, binary); }