logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Test::HexDifferences - Test binary as hexadecimal string

Author

       Steffen Winkler

Bugs And Limitations

       none

Configuration And Environment

       nothing

Dependencies

       Sub::Exporter

       Test::Builder::Module

       Test::HexDifferences::HexDump

       Text::Diff

Description

       The are some special cases for testing binary data.

       •   The ascii format is not good for e.g. a length byte 0x41 displayed as A.

       •   Multibyte values are better shown as 1 value.

       •   Structured binary e.g. 2 byte length followed by bytes better are shown as it is.

       •   Compare 2 binary or 1 binary and a dump.

Diagnostics

       nothing

Example

       Inside of this Distribution is a directory named example.  Run this *.t files.

Incompatibilities

       none

Name

       Test::HexDifferences - Test binary as hexadecimal string

See Also

       Test::HexDifferences::HexDump

Subroutines/Methods

subroutineeq_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
           );

   subroutinedumped_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
           );

Synopsis

           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,
           );

       If $got or $expected is "undef" or a reference, the hexadecimal formatter is off.  Then "eq_or_dump_diff"
       is a text compare.

           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,
           );

       See Test::HexDifferences::HexDump for the format description.

Version

       1.001

See Also