Test::BinaryData

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

Test::BinaryData Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Ricardo Signes
  • Publisher web site:
  • http://search.cpan.org/~rjbs/

Test::BinaryData Tags


Test::BinaryData Description

Test::BinaryData is 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 # ... Requirements: · Perl


Test::BinaryData Related Software