@Test
public void testReadBits() throws Exception {

  assertThat(readBits((byte) 0x00, 2, 2)).isEqualTo(0);
  assertThat(readBits((byte) 0x02, 1, 1)).isEqualTo(1);
  assertThat(readBits((byte) 0xF0, 4, 4)).isEqualTo(15);
  assertThat(readBits((byte) 0x80, 1, 7)).isEqualTo(1);
}