File: Audio-File.t

package info (click to toggle)
libaudio-file-perl 0.11-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 288 kB
  • sloc: perl: 498; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,350 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl

use Test::More tests => 49;

BEGIN { use_ok('Audio::File'); }

my $tags = {
	Flac	=> {
		title	=> 'Title',
		artist	=> 'Artist',
		album	=> 'Album',
		comment	=> 'Comment',
		genre	=> 'Rock',
		year	=> 2005,
		track	=> 2,
		total	=> 3
	}
};
$tags->{Mp3} = $tags->{Ogg} = $tags->{Flac};

my $audio_properties = {
	Flac	=> {
		length		=> 4,
		bitrate		=> 94910,
		sample_rate	=> 8000,
		channels	=> 1
	},
	Ogg		=> {
		length		=> 4,
		bitrate		=> 28000,
		sample_rate	=> 8000,
		channels	=> 1
	},
	Mp3		=> {
		length		=> 4,
		bitrate		=> 8,
		sample_rate	=> 8000,
		channels	=> 1
	}
};

for my $type (keys %{$tags}) {
	my $file = Audio::File->new('t/test.'.lc($type));
	is( ref $file, "Audio::File::${type}", 'Audio::File::new()' );
	is( $file->type(), lc $type, 'Audio::File::Type::type()' );

	is( ref $file->tag(), "Audio::File::${type}::Tag", "Audio::File::${type}::tag()" );
	is( ref $file->audio_properties(), "Audio::File::${type}::AudioProperties", "Audio::File::${type}::audio_properties()" );

	for my $test (keys %{$tags->{$type}}) {
		is( $file->tag()->$test(), $tags->{$type}->{$test}, "Audio::File::${type}::Tag::${test}()" );
	}

	for my $test (keys %{$audio_properties->{$type}}) {
		is( $file->audio_properties()->$test(), $audio_properties->{$type}->{$test}, "Audio::File::${type}::AudioProperties::${test}()" );
	}
}