File: basic.t

package info (click to toggle)
libnet-daap-dmap-perl 1.26-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 128 kB
  • ctags: 15
  • sloc: perl: 684; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 866 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!perl
use strict;
use warnings;
my @dmap_files;
BEGIN { @dmap_files = <t/*.dmap> }
use Test::More tests => scalar @dmap_files;
use Net::DAAP::DMAP qw( dmap_unpack dmap_pack );

sub is_binary ($$;$) {
    $_[0] =~ s{([^[:print:]])}{sprintf "<%02x>", ord $1}ge;
    $_[1] =~ s{([^[:print:]])}{sprintf "<%02x>", ord $1}ge;
    goto &is;
}
if (eval "use Data::HexDump; use Test::Differences; 1") {
    no warnings 'redefine';
    *is_binary = sub ($$;$) {
        my ($value, $expected, $reason) = @_;
        eq_or_diff( HexDump( $value ), HexDump( $expected ), $reason );
    };
}

for my $file (@dmap_files) {
    local $TODO = "Fix Net::DAAP::DMAP to understand the new content codes"
      if  $file =~ /server-info/;
    my $data = do { open my $fh, '<', $file; local $/; <$fh> };
    is_binary( dmap_pack( dmap_unpack( $data ) ), $data, "$file round trips" );
}