]>
Commit | Line | Data |
---|---|---|
a3f1cbda MG |
1 | #!/usr/bin/perl |
2 | use strict; | |
3 | use warnings; | |
4 | ||
b9bd6a0d | 5 | use Test::More tests => 23; |
a3f1cbda MG |
6 | BEGIN { use_ok('Audio::Opusfile') }; |
7 | ||
8 | my $fail = 0; | |
9 | foreach my $constname (qw( | |
10 | OPUS_CHANNEL_COUNT_MAX OP_ABSOLUTE_GAIN OP_DEC_FORMAT_FLOAT | |
11 | OP_DEC_FORMAT_SHORT OP_DEC_USE_DEFAULT OP_EBADHEADER OP_EBADLINK | |
12 | OP_EBADPACKET OP_EBADTIMESTAMP OP_EFAULT OP_EIMPL OP_EINVAL OP_ENOSEEK | |
13 | OP_ENOTAUDIO OP_ENOTFORMAT OP_EOF OP_EREAD OP_EVERSION OP_FALSE | |
14 | OP_GET_SERVER_INFO_REQUEST OP_HEADER_GAIN OP_HOLE | |
15 | OP_HTTP_PROXY_HOST_REQUEST OP_HTTP_PROXY_PASS_REQUEST | |
16 | OP_HTTP_PROXY_PORT_REQUEST OP_HTTP_PROXY_USER_REQUEST OP_PIC_FORMAT_GIF | |
17 | OP_PIC_FORMAT_JPEG OP_PIC_FORMAT_PNG OP_PIC_FORMAT_UNKNOWN | |
18 | OP_PIC_FORMAT_URL OP_SSL_SKIP_CERTIFICATE_CHECK_REQUEST OP_TRACK_GAIN)) { | |
19 | next if (eval "my \$a = $constname; 1"); | |
20 | if ($@ =~ /^Your vendor has not defined Audio::Opusfile macro $constname/) { | |
21 | print "# pass: $@"; | |
22 | } else { | |
23 | print "# fail: $@"; | |
24 | $fail = 1; | |
25 | } | |
26 | ||
27 | } | |
28 | ||
29 | ok( $fail == 0 , 'Constants' ); | |
30 | ||
31 | my $of = Audio::Opusfile->new_from_file('empty.opus'); | |
5fbea9a2 MG |
32 | ok $of->seekable, 'seekable'; |
33 | is $of->link_count, 1, 'link_count'; | |
34 | is $of->serialno(0), 1745145935, 'serialno, arg=0'; | |
35 | is $of->serialno(200), 1745145935, 'serialno, arg=200'; | |
36 | is $of->serialno, 1745145935, 'serialno, no arg'; | |
b9bd6a0d MG |
37 | |
38 | my $head = $of->head; | |
39 | is $head->version, 1, 'head->version'; | |
40 | is $head->channel_count, 2, 'head->channel_count'; | |
41 | is $head->pre_skip, 356, 'head->pre_skip'; | |
42 | is $head->input_sample_rate, 44100, 'head->input_sample_rate'; | |
43 | is $head->output_gain, 0, 'head->output_gain'; | |
44 | is $head->mapping_family, 0, 'head->mapping_family'; | |
45 | is $head->stream_count, 1, 'head->stream_count'; | |
46 | is $head->coupled_count, 1, 'head->coupled_count'; | |
47 | is $head->mapping(0), 0, 'head->mapping(0)'; | |
48 | is $head->mapping(1), 1, 'head->mapping(1)'; | |
49 | eval { $head->mapping(1000) }; | |
50 | isn::t $@, '', 'head->mapping(1000) dies'; | |
51 | ||
a3f1cbda MG |
52 | my $tags = $of->tags; |
53 | is $tags->query_count('TITLE'), 1, 'query_count'; | |
54 | is $tags->query('TITLE'), 'Cellule', 'query'; | |
55 | is_deeply [$tags->query_all('TITLE')], ['Cellule'], 'query_all'; | |
5fbea9a2 MG |
56 | |
57 | open my $fh, '<', 'empty.opus'; | |
58 | read $fh, my $buf, 100; | |
59 | ok Audio::Opusfile::test($buf), 'test'; | |
60 | ||
61 | seek $fh, 0, 0; | |
62 | read $fh, $buf, 20000; | |
63 | $of = Audio::Opusfile->new_from_memory($buf); | |
64 | is $of->tags->query('TITLE'), 'Cellule', 'new_from_memory + query'; |