@Test
public void decode () throws Exception {

  val bits = new byte[] { 1, 2, 3 };
  val pad = 3;
  val bytes = Bytes.resizableArray()
      .write1B(BIT_BINNARY.getCode())
      .write4B(bits.length)
      .write1B(8 - pad)
      .writeNB(new byte[] { 1, 2, 0 })
      .arrayCopy();
  try (val input = new OtpInputStream(bytes)) {
    ErlangBitString bitString = ErlangTerm.newInstance(wrappedBuffer(bytes));
    assertThat(bitString.getBits())
        .isEqualTo(input.read_bitstr(new int[1]));
  }
}