X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=t%2FApp-MusicExpo.t;h=09b2bde29c9ba1261943134b34d30f8ffd9c4f3d;hb=b484a12921835e84ece975361da2c7b209beba6b;hp=0ad611b96208b034564e138208e951722c1a5ff3;hpb=238670541686b36bd6f4698f9fb3c091660f9b34;p=app-musicexpo.git diff --git a/t/App-MusicExpo.t b/t/App-MusicExpo.t index 0ad611b..09b2bde 100644 --- a/t/App-MusicExpo.t +++ b/t/App-MusicExpo.t @@ -1,32 +1,36 @@ -#!/usr/bin/perl -wT -CSDA +#!/usr/bin/perl -wT use v5.14; use warnings; -use Test::More tests => 19; +use Test::More tests => 37; +use Scalar::Util qw/looks_like_number/; use Storable qw/thaw/; BEGIN { use_ok('App::MusicExpo'); } -my $flacinfo = thaw App::MusicExpo::flacinfo 'empty.flac'; -my $mp3info = thaw App::MusicExpo::mp3info 'empty.mp3'; +my %data = ( + title => 'Cellule', + artist => 'Silence', + year => 2005, + album => 'L\'autre endroit', + tracknumber => 1, + tracktotal => 9, + genre => 'Electro' +); -is $flacinfo->{format}, 'FLAC', 'flacinfo format'; -is $flacinfo->{title}, 'Cellule', 'flacinfo title'; -is $flacinfo->{artist}, 'Silence', 'flacinfo artist'; -is $flacinfo->{year}, 2005, 'flacinfo year'; -is $flacinfo->{album}, 'L\'autre endroit', 'flacinfo album'; -is $flacinfo->{tracknumber}, '01', 'flacinfo tracknumber'; -is $flacinfo->{tracktotal}, '09', 'flacinfo tracktotal'; -is $flacinfo->{genre}, 'Electro', 'flacinfo genre'; -is $flacinfo->{path}, '/music/empty.flac', 'flacinfo path'; +sub test { + my ($format, $sub, $file) = @_; + my $info = thaw $sub->($file); + is $info->{format}, $format, "$format format"; + for (sort keys %data) { + my $op = looks_like_number $data{$_} ? '==' : 'eq'; + cmp_ok $info->{$_}, $op, $data{$_}, "$format $_" + } + is $info->{file}, $file, "$format file"; +} -is $mp3info->{format}, 'MP3', 'mp3info format'; -is $mp3info->{title}, 'Cellule', 'mp3info title'; -is $mp3info->{artist}, 'Silence', 'mp3info artist'; -is $mp3info->{year}, 2005, 'mp3info year'; -is $mp3info->{album}, 'L\'autre endroit', 'mp3info album'; -is $mp3info->{tracknumber}, '01', 'mp3info tracknumber'; -is $mp3info->{tracktotal}, '09', 'mp3info tracktotal'; -is $mp3info->{genre}, 'Electro', 'mp3info genre'; -is $mp3info->{path}, '/music/empty.mp3', 'mp3info path'; +test FLAC => \&App::MusicExpo::flacinfo, 'empty.flac'; +test MP3 => \&App::MusicExpo::mp3info, 'empty3.mp3'; +test Vorbis => \&App::MusicExpo::vorbisinfo, 'empty.ogg'; +test AAC => \&App::MusicExpo::mp4info, 'empty4.aac';