FUNCTIONS

is_binary

is_binary($have, $want, $comment, \%arg);

This test behaves like Test::More's is test, but if the given data are not string equal, the diagnostics emits four columns, describing the strings in parallel, showing a simplified ASCII representation and a hexadecimal dump.

If $want is an arrayref, it's treated as a sequence of strings giving hex values for expected bytes. For example, this is a passing test:

is_binary(
"Mumblefrotz",
[ qw(4d75 6d62 6c65 6672 6f74 7a0a) ],
);

Notice that each string in the sequence is broken into two-character pieces. This makes this interface accept the kind of dumps produced by xxd or Test::BinaryData itself.

Between the got and expected data for each line, a "=" or "!" indicates whether the chunks are identical or different.

The $comment and %arg arguments are optional. Valid arguments are:

columns - the number of screen columns available
if the COLUMNS environment variable is an positive integer, then
COLUMNS - is used; otherwise, the default is 79
max_diffs - if given, this is the maximum number of differing lines that will
be compared; if output would have been given beyond this line,
it will be replaced with an elipsis ("...")

WARNING

This library is for comparing binary data. That is, byte strings. Often, in Perl 5, it is not clear whether a scalar contains a byte string or a character strings. You should use this library for comparing byte strings only. If either the "have" or "want" values contain wide characters -- that is, characters that won't fit in one byte -- then the test will fail.

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.