| 1 | #!/usr/bin/perl -wT |
| 2 | use v5.14; |
| 3 | use warnings; |
| 4 | |
| 5 | use Test::More tests => 37; |
| 6 | |
| 7 | use Scalar::Util qw/looks_like_number/; |
| 8 | use Storable qw/thaw/; |
| 9 | |
| 10 | BEGIN { use_ok('App::MusicExpo'); } |
| 11 | |
| 12 | my %data = ( |
| 13 | title => 'Cellule', |
| 14 | artist => 'Silence', |
| 15 | year => 2005, |
| 16 | album => 'L\'autre endroit', |
| 17 | tracknumber => 1, |
| 18 | tracktotal => 9, |
| 19 | genre => 'Electro' |
| 20 | ); |
| 21 | |
| 22 | sub test { |
| 23 | my ($format, $sub, $file) = @_; |
| 24 | my $info = thaw $sub->($file); |
| 25 | is $info->{format}, $format, "$format format"; |
| 26 | for (sort keys %data) { |
| 27 | my $op = looks_like_number $data{$_} ? '==' : 'eq'; |
| 28 | cmp_ok $info->{$_}, $op, $data{$_}, "$format $_" |
| 29 | } |
| 30 | is $info->{file}, $file, "$format file"; |
| 31 | } |
| 32 | |
| 33 | test FLAC => \&App::MusicExpo::flacinfo, 'empty.flac'; |
| 34 | test MP3 => \&App::MusicExpo::mp3info, 'empty3.mp3'; |
| 35 | test Vorbis => \&App::MusicExpo::vorbisinfo, 'empty.ogg'; |
| 36 | test AAC => \&App::MusicExpo::mp4info, 'empty4.aac'; |