Test::...rences(3pm)

πŸ“¦
version 1.001 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so bestie, this is the manual page for Test::HexDifferences β€” it's Test::...rences(3pm) if you're reading the header up top, and it lives in the User Contributed Perl Documentation section. What it does? Test binary as hexadecimal string. That's the whole vibe. πŸ¦‹


✨ VERSION ✨

1.001 β€” that's the one, no cap.


🧚 SYNOPSIS 🧚

okay bestie, here's the whole menu of ways you can call this thing πŸ’…

use Test::HexDifferences;

eq_or_dump_diff(
    $got,
    $expected,
);

eq_or_dump_diff(
    $got,
    $expected,
    $test_name,
);

eq_or_dump_diff(
    $got,
    $expected,
    {
        address => $start_address,
        format  => "%a : %4C : %d\n",
    }
    $test_name,
);

and here's the tea: if $got or $expected is "undef" or a reference, the hexadecimal formatter is OFF. like, fully off. and then eq_or_dump_diff is just a text compare. that's it, that's the rule. πŸ™ˆ

dumped_eq_dump_or_diff(
    $got_value,
    $expected_dump,
);

dumped_eq_dump_or_diff(
    $got_value,
    $expected_dump,
    $test_name,
);

dumped_eq_dump_or_diff(
    $got_value,
    $expected_dump,
    {
        address => $start_address,
        format  => "%a : %4C : %d\n",
    }
    $test_name,
);

want the full deets on the format string? go peek at Test::HexDifferences::HexDump for the format description πŸ‘‘


🌸 EXAMPLE 🌸

inside of this Distribution there's a directory named example β€” yes, lowercase, iconic. go run those *.t files, they're literally right there. πŸ“


πŸ’œ DESCRIPTION πŸ’œ

so the thing is, testing binary data has some special cases and we gotta talk about them:

  • the ascii format is not good for stuff like a length byte 0x41 that just gets displayed as A. like ma'am that is not helpful 😭
  • multibyte values are way better shown as 1 value. one. single. value. periodt.
  • structured binary β€” think 2 byte length followed by bytes β€” is better shown as it is. don't touch it, let it be its authentic self 🫢
  • and the whole point: compare 2 binary, or 1 binary and a dump ✨

πŸ‘‘ SUBROUTINES/METHODS πŸ‘‘

subroutine eq_or_dump_diff

eq_or_dump_diff(
    $got_value,
    $expected_value,
    {                                      # optional hash reference
        address => $display_start_address, # optional
        format  => $format_string,         # optional
    }
    $test_name,                            # optional
);

subroutine dumped_eq_dump_or_diff

dumped_eq_dump_or_diff(
    $got_value,
    $expected_dump,
    {                                      # optional hash reference
        address => $display_start_address, # optional
        format  => $format_string,         # optional
    }
    $test_name,                            # optional
);

πŸŽ€ DIAGNOSTICS πŸŽ€

nothing πŸ’€ β€” literally nothing to report, she's quiet.


🌈 CONFIGURATION AND ENVIRONMENT 🌈

nothing β€” no environment variables, no config, no drama. we love a low-maintenance queen πŸ’…


⭐ DEPENDENCIES ⭐

these are the besties she rolls with:

  • Sub::Exporter
  • Test::Builder::Module
  • Test::HexDifferences::HexDump
  • Text::Diff

πŸ’€ INCOMPATIBILITIES πŸ’€

none β€” she gets along with everybody 🫢


πŸ™ˆ BUGS AND LIMITATIONS πŸ™ˆ

none β€” flawless, obviously πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯

  • Test::HexDifferences::HexDump

πŸ’… AUTHOR πŸ’…

Steffen Winkler β€” the icon, the moment, the main character πŸŽ€


Copyright (c) 2012 - 2015, Steffen Winkler "<steffenw at cpan.org>". All rights reserved.

this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay. ✨


okay bestie that's the whole page πŸ¦‹ this was perl v5.30.3, dated 2020-08-04, filed under Test::...rences(3pm) β€” mwah, take care, go test your bytes πŸ’–

πŸ“¦ where this page comes from