3 # This file is part of Audio::MPD.
4 # Copyright (c) 2007 Jerome Quelin <jquelin@cpan.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or (at
9 # your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 use Test::More tests => 18;
28 my ($i, $output, @output, %params);
31 # testing audio::mpd::item::song
32 $output = 'file: some/random/path/to/a/song.ogg
41 @output = split /\n/, $output;
42 %params = map { /^([^:]+):\s+(.*)$/ ? ($1=>$2) : () } @output;
43 $i = Audio::MPD::Item->new( %params );
44 isa_ok( $i, 'Audio::MPD::Item::Song', 'song creation' );
45 is( $i->file, 'some/random/path/to/a/song.ogg', 'accessor: file' );
46 is( $i->time, 234, 'accessor: time' );
47 is( $i->artist, 'Foo Bar', 'accessor: artist' );
48 is( $i->album, 'Frobnizer', 'accessor: album' );
49 is( $i->track, 26, 'accessor: track' );
50 is( $i->title, 'Blah!', 'accessor: title' );
51 is( $i->pos, 10, 'accessor: pos' );
52 is( $i->id, 14, 'accessor: id' );
53 isa_ok( $i, 'Audio::MPD::Item', 'song inherits from item' );
57 # testing as_string from audio::mpd::item::song.
58 is( $i->as_string, 'Frobnizer = 26 = Foo Bar = Blah!', 'as_string() with all tags' );
60 is( $i->as_string, 'Foo Bar = Blah!', 'as_string() without track' );
61 $i->track(26); $i->album(undef);
62 is( $i->as_string, 'Foo Bar = Blah!', 'as_string() without album' );
64 is( $i->as_string, 'Blah!', 'as_string() without artist' );
66 is( $i->as_string, 'some/random/path/to/a/song.ogg', 'as_string() without title' );
70 # testing audio::mpd::item::directory
71 $output = "directory: some/random/path\n";
72 @output = split /\n/, $output;
73 %params = map { /^([^:]+):\s+(.*)$/ ? ($1=>$2) : () } @output;
74 $i = Audio::MPD::Item->new( %params );
75 isa_ok( $i, 'Audio::MPD::Item::Directory', 'directory creation' );
76 is( $i->directory, 'some/random/path', 'accessor: directory' );
77 isa_ok( $i, 'Audio::MPD::Item', 'directory inherits from item' );