Test::Bits(3pm)

πŸ“¦
version 0.02 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Test::Bits ✨

okay bestie so this is the Test::Bits page from the User Contributed Perl Documentation (that's the 3pm energy, iykyk) and it's literally just here to hand you one (1) little subroutine that tests binary data. that's it. that's the whole vibe. πŸŽ€


🌸 NAME 🌸

Test::Bits β€” provides a bits_is() subroutine for testing binary data πŸ’…


πŸ’– VERSION πŸ’–

version 0.02


✨ SYNOPSIS ✨

okay here's the whole moment, look at her:

use Test::Bits;

bits_is(
    $binary_data,
    [ 0b0010101, 0b01111100 ],
    'binary data contains expected values'
);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this module gives you exactly one subroutine, bits_is(), and its whole job is testing binary data. one job. iconic behavior fr. 🌟

conceptually? she's lowkey cousins with Test::BinaryData and Test::HexString. the difference is that this module shows failure diagnostics in a different way, and the calling style is a slightly different flavor. depending on the nature of the data you're working with, this module might just be easier to work with. it's giving "the right tool for the right girlie." 🫢

specifically: when you're doing a lot of bit twiddling, this module's diagnostic output may make it easier to diagnose failures. a typical failure diagnostic looks like this:

The two pieces of binary data are not the same length (got 2, expected 3).
Binary data begins differing at byte 1.
  Got:    01111000
  Expect: 01111001
heads up bestie: the bytes are numbered starting from 0 in the diagnostic output. zero-indexed girlies, we stay winning. πŸ’€

🌈 USAGE 🌈

the bits_is() subroutine takes two required arguments and an optional test name. three slots, no notes. πŸŽ€

  • the first argument should be a plain scalar containing binary data. if it contains any UTF-8 characters, an error will be thrown. 🚨 so like... don't do that.
  • the second argument should be an array reference of numbers from 0-255 representing the expected value of each byte in the first argument.

and the reason that second one slaps so hard is that it lets you write the numbers out in binary format (0bXXXXXXXX) for your test cases if you want to. bit-coded test cases, periodt. ⭐


πŸ’œ BUGS πŸ’œ

found a bug or want a feature? please report it, bestie, we wanna know!! πŸ™ˆ

  • mail it to bug-test-bits@rt.cpan.org
  • or go through the web interface at http://rt.cpan.org

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. that's the deal. tracking numbers, transparency, all of it. πŸ‘‘


πŸ‘‘ AUTHOR πŸ‘‘

Dave Rolsky <autarch@urth.org>


this software is Copyright (c) 2013 by MaxMind, Inc.. πŸ’–

this is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

so yeah, that's the whole page β€” Test::Bits, version 0.02, from the User Contributed Perl Documentation, dated 2022-11-20 and built for perl v5.36.0. go forth and test your binary data, bestie, you're gonna slay it πŸ’…βœ¨πŸ¦‹