This module provides a single subroutine, bits_is(), for testing binary
This module is quite similar to Test::BinaryData and Test::HexString in
concept. The difference is that this module shows failure diagnostics in a
different way, and has a slightly different calling style. Depending on the
nature of the data youre working with, this module may be easier to work with.
In particular, when youre doing a lot of bit twiddling, this modules
diagnostic output may make it easier to diagnose failures. A typical failure
diagnostic will look like this:
The two pieces of binary data are not the same length (got 2, expected 3).
Binary data begins differing at byte 1.
Note that the bytes are numbered starting from 0 in the diagnostic output.
The bits_is() subroutine takes two required arguments and an optional test
The first argument should be a plain scalar containing binary data. If it
contains any UTF-8 characters an error will be thrown.
The second argument should be an array reference of numbers from 0-255
representing the expected value of each byte in the first argument.
This allows you write the numbers out in binary format (0bXXXXXXXX) for test
cases if you wish to.