Load tag-reading modules on demand
[app-musicexpo.git] / t / App-MusicExpo.t
1 #!/usr/bin/perl -wT
2 use v5.14;
3 use warnings;
4
5 use Test::More tests => 46;
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 my %handled = map { $_ => 1 } App::MusicExpo::extensions_handled;
23
24 sub test {
25 my ($format, $sub, $file) = @_;
26 my ($ext) = $file =~ /(\..+)$/;
27
28 SKIP:
29 {
30 skip "Cannot handle $ext files (tag-reading module missing)", 9 unless $handled{$ext};
31 my $info = thaw $sub->($file);
32 is $info->{format}, $format, "$format format";
33 for (sort keys %data) {
34 my $op = looks_like_number $data{$_} ? '==' : 'eq';
35 cmp_ok $info->{$_}, $op, $data{$_}, "$format $_"
36 }
37 is $info->{file}, $file, "$format file";
38 }
39 }
40
41 test FLAC => \&App::MusicExpo::flacinfo, 'empty.flac';
42 test MP3 => \&App::MusicExpo::mp3info, 'empty3.mp3';
43 test Vorbis => \&App::MusicExpo::vorbisinfo, 'empty.ogg';
44 test AAC => \&App::MusicExpo::mp4info, 'empty4.aac';
45 test Opus => \&App::MusicExpo::opusinfo, 'empty2.opus';
This page took 0.025686 seconds and 4 git commands to generate.