1Test::Bits(3)         User Contributed Perl Documentation        Test::Bits(3)
2
3
4

NAME

6       Test::Bits - Provides a bits_is() subroutine for testing binary data
7

VERSION

9       version 0.02
10

SYNOPSIS

12         use Test::Bits;
13
14         bits_is(
15             $binary_data,
16             [ 0b0010101, 0b01111100 ],
17             'binary data contains expected values'
18         );
19

DESCRIPTION

21       This module provides a single subroutine, "bits_is()", for testing
22       binary data.
23
24       This module is quite similar to Test::BinaryData and Test::HexString in
25       concept. The difference is that this module shows failure diagnostics
26       in a different way, and has a slightly different calling style.
27       Depending on the nature of the data you're working with, this module
28       may be easier to work with.
29
30       In particular, when you're doing a lot of bit twiddling, this module's
31       diagnostic output may make it easier to diagnose failures. A typical
32       failure diagnostic will look like this:
33
34          The two pieces of binary data are not the same length (got 2, expected 3).
35          Binary data begins differing at byte 1.
36            Got:    01111000
37            Expect: 01111001
38
39       Note that the bytes are numbered starting from 0 in the diagnostic
40       output.
41

USAGE

43       The "bits_is()" subroutine takes two required arguments and an optional
44       test name.
45
46       The first argument should be a plain scalar containing binary data. If
47       it contains any UTF-8 characters an error will be thrown.
48
49       The second argument should be an array reference of numbers from 0-255
50       representing the expected value of each byte in the first argument.
51
52       This allows you write the numbers out in binary format (0bXXXXXXXX) for
53       test cases if you wish to.
54

BUGS

56       Please report any bugs or feature requests to
57       "bug-test-bits@rt.cpan.org", or through the web interface at
58       <http://rt.cpan.org>. I will be notified, and then you'll automatically
59       be notified of progress on your bug as I make changes.
60

AUTHOR

62       Dave Rolsky <autarch@urth.org>
63
65       This software is Copyright (c) 2013 by MaxMind, Inc..
66
67       This is free software, licensed under:
68
69         The Artistic License 2.0 (GPL Compatible)
70
71
72
73perl v5.32.1                      2021-01-27                     Test::Bits(3)
Impressum