Make tests and code slightly shorter
[app-musicexpo.git] / t / App-MusicExpo.t
CommitLineData
8086953c 1#!/usr/bin/perl -wT
21cd9240
MG
2use v5.14;
3use warnings;
4
12d4da0a 5use Test::More tests => 37;
21cd9240 6
b484a129 7use Scalar::Util qw/looks_like_number/;
21cd9240
MG
8use Storable qw/thaw/;
9
10BEGIN { use_ok('App::MusicExpo'); }
11
b484a129
MG
12my %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
22sub 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
33test FLAC => \&App::MusicExpo::flacinfo, 'empty.flac';
34test MP3 => \&App::MusicExpo::mp3info, 'empty3.mp3';
35test Vorbis => \&App::MusicExpo::vorbisinfo, 'empty.ogg';
36test AAC => \&App::MusicExpo::mp4info, 'empty4.aac';
This page took 0.011713 seconds and 4 git commands to generate.