File: write.t

package info (click to toggle)
libaudio-flac-header-perl 2.4-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 416 kB
  • sloc: perl: 2,431; makefile: 3
file content (56 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -w

use strict;
use Test::More tests => 7;

use File::Spec::Functions qw(:ALL);
use File::Copy;

BEGIN { use_ok('Audio::FLAC::Header') };

#########################

{
        # Always test pure perl
        my @modes = ('PP');

        # Only test XS if built
        SKIP: {
                eval { Audio::FLAC::Header->_new_XS(catdir('data', 'empty.flac')) };
                skip "Not built with XS", 3 if $@;

                push @modes, 'XS';
        }

        # Be sure to test both code paths.
        for my $mode (@modes) {

		my $constructor  = "_new_$mode";
		my $write_method = "_write_$mode";

		my $empty = catdir('data', 'empty.flac');
		my $write = catdir('data', "write_$mode.flac");

		copy($empty, $write);

		my $flac = Audio::FLAC::Header->$constructor($write);

		ok($flac, "constructor: $constructor");

		my $tags = $flac->tags;

		$tags->{'ALBUM'} = 'FOO';

		ok($flac->$write_method, "Wrote out tags");

		undef $flac;

		my $read = Audio::FLAC::Header->$constructor($write);

		ok($read->tags('ALBUM') eq 'FOO', "Got written out tags");

		unlink($write);
	}
}

__END__