]> diplodocus.org Git - flac-archive/blob - t/filenames.t
574c648e31830884c8ea76d49f5b0bb4c162b2b9
[flac-archive] / t / filenames.t
1 use v5.12;
2 use warnings;
3
4 use Test::More tests => 6;
5
6 use FindBin;
7
8 use lib "$FindBin::Bin/..";
9
10 require 'tags.pl';
11 epg::flac::archive::tags->import('track_tags_from_disc');
12 require 'fa-encode';
13
14 is epg::flac::archive::encode::filename(
15 3,
16 {
17 DISCNUMBER => [2],
18 TITLE => ['the title'],
19 }
20 ),
21 '02-03-the_title.flac',
22 'with discnumber';
23
24 is
25 epg::flac::archive::encode::filename(1, {TITLE => ['the title']}),
26 '01-the_title.flac',
27 'without discnumber';
28
29 my $album = {
30 ARTIST => ['Marillion'],
31 ALBUM => ["An Hour Before It's Dark"],
32 DATE => ['2022-03-04'],
33 };
34 my $tracks = [
35 {
36 TITLE => ['Care'],
37 PART => ['IV. Angels On Earth'],
38 PARTNUMBER => [4],
39 },
40 {
41 TITLE => ['(silence)'],
42 },
43 {
44 TITLE => ['Murder Machines'],
45 VERSION => ['12 inch remix'],
46 },
47 {
48 TITLE => ['testing both and with leading 0'],
49 PARTNUMBER => ['04'],
50 VERSION => ['live'],
51 },
52 {
53 TITLE => ['(silence)'],
54 },
55 {
56 TITLE => ['Murder Machines'],
57 VERSION => ['12 inch remix'],
58 },
59 ];
60 is epg::flac::archive::encode::filename(
61 1, {epg::flac::archive::tags::track_tags_from_disc($album, $tracks, 1)},
62 ),
63 '01-Care-4.flac',
64 'PART goes into filename, PARTNUMBER ignored';
65
66 is epg::flac::archive::encode::filename(
67 2, {epg::flac::archive::tags::track_tags_from_disc($album, $tracks, 2)},
68 ),
69 '02-silence.flac',
70 'parens in track title omitted';
71
72 is epg::flac::archive::encode::filename(
73 3, {epg::flac::archive::tags::track_tags_from_disc($album, $tracks, 3)},
74 ),
75 '03-Murder_Machines-12_inch_remix.flac',
76 'VERSION goes into filename';
77
78 is epg::flac::archive::encode::filename(
79 4, {epg::flac::archive::tags::track_tags_from_disc($album, $tracks, 4)},
80 ),
81 '04-testing_both_and_with_leading_0-live-04.flac',
82 'PARTNUMBER with leading 0 and VERSION';