Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    Test::BinaryData 0.007

    Download button

    No screenshots available
    Downloads: 354  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.2/5)
    12 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Ricardo Signes | More programs
    Perl Artistic License / FREE
    April 10th, 2008, 08:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Test::BinaryData description

    A Perl module that allows you to compare two things, give hex dumps if they differ.

    Test::BinaryData is a Perl module that allows you to compare two things, give hex dumps if they differ.

    SYNOPSIS

    use Test::BinaryData;

    my $computed_data = do_something_complicated;
    my $expected_data = read_file('correct.data');

    is_binary(
    $computed_data,
    $expected_data,
    "basic data computation",
    );


    Sometimes using Test::More's is test isn't good enough. Its diagnostics may make it easy to miss differences between strings.

    For example, given two strings which differ only in their line endings, you can end up with diagnostic output like this:

    not ok 1
    # Failed test in demo.t at line 8.
    # got: 'foo
    # bar
    # '
    # expected: 'foo
    # bar
    # '


    That's not very helpful, except to tell you that the alphanumeric characters seem to be in the right place. By using is_binary instead of is, this output would be generated instead:

    not ok 2
    # Failed test in demo.t at line 10.
    # got (hex) got expect (hex) expect
    # 666f6f0a6261720a---- foo.bar. ! 666f6f0d0a6261720d0a foo..bar..


    The "!" tells us that the lines differ, and we can quickly scan the bytes that make up the line to see which differ.

    When comparing very long strings, we can stop after we've seen a few differences. Here, we'll just look for two:

    # got (hex) got expect (hex) expect
    # 416c6c20435220616e64 All CR and = 416c6c20435220616e64 All CR and
    # 206e6f204c46206d616b no LF mak = 206e6f204c46206d616b no LF mak
    # 6573204d616320612064 es Mac a d = 6573204d616320612064 es Mac a d
    # 756c6c20626f792e0d41 ull boy..A = 756c6c20626f792e0d41 ull boy..A
    # 6c6c20435220616e6420 ll CR and = 6c6c20435220616e6420 ll CR and
    # 6e6f204c46206d616b65 no LF make = 6e6f204c46206d616b65 no LF make
    # 73204d61632061206475 s Mac a du = 73204d61632061206475 s Mac a du
    # 6c6c20626f792e0d416c ll boy..Al ! 6c6c20626f792e0a416c ll boy..Al
    # 6c20435220616e64206e l CR and n = 6c20435220616e64206e l CR and n
    # 6f204c46206d616b6573 o LF makes = 6f204c46206d616b6573 o LF makes
    # 204d616320612064756c Mac a dul = 204d616320612064756c Mac a dul
    # 6c20626f792e0d416c6c l boy..All ! 6c20626f792e0a416c6c l boy..All
    # 20435220616e64206e6f CR and no = 20435220616e64206e6f CR and no
    # ...


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    hex dumps | compare files | Perl module | hex | dumps | compare

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM