]>
Commit | Line | Data |
---|---|---|
8086953c | 1 | #!/usr/bin/perl -wT |
21cd9240 MG |
2 | use v5.14; |
3 | use warnings; | |
4 | ||
f7964165 | 5 | use Test::More tests => 46; |
21cd9240 | 6 | |
b484a129 | 7 | use Scalar::Util qw/looks_like_number/; |
21cd9240 MG |
8 | use Storable qw/thaw/; |
9 | ||
10 | BEGIN { use_ok('App::MusicExpo'); } | |
11 | ||
b484a129 MG |
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 | ||
f7964165 MG |
22 | my %handled = map { $_ => 1 } App::MusicExpo::extensions_handled; |
23 | ||
b484a129 MG |
24 | sub test { |
25 | my ($format, $sub, $file) = @_; | |
f7964165 MG |
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"; | |
b484a129 | 38 | } |
b484a129 MG |
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'; | |
f7964165 | 45 | test Opus => \&App::MusicExpo::opusinfo, 'empty2.opus'; |