a37fe6fcffcb1a0c26c59269594f897173617a3f
[Data-Peek.git] / t / 22_DHexDump.t
bloba37fe6fcffcb1a0c26c59269594f897173617a3f
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use Test::More;
7 #use Test::NoWarnings;
9 use Data::Peek;
11 is (DHexDump (undef), undef, 'undef');
12 is (DHexDump (""), "", '""');
14 for (split m/##\n/ => test_data ()) {
15 my ($desc, $in, $out) = split m/\n-\n/, $_, 3;
17 is (scalar DHexDump ($in), $out, "HexDump $desc");
20 done_testing;
22 sub test_data
24 return <<"EOTD";
25 Single 0
29 0000 30 0
31 Documentation example
33 abc\x{0a}de\x{20ac}fg
35 0000 61 62 63 0a 64 65 e2 82 ac 66 67 abc.de...fg
37 Binary data
39 \x01Great wide open space\x02\x{20ac}\n
41 0000 01 47 72 65 61 74 20 77 69 64 65 20 6f 70 65 6e .Great wide open
42 0010 20 73 70 61 63 65 02 e2 82 ac 0a space.....
44 EOTD
45 } # test_data