#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 13;
use XML::RSS;
use File::Spec;
{
my $rss = XML::RSS->new();
$rss->parse(<<"EOF");
Journalism - Topix.net
http://www.topix.net/news/journalism
News on Journalism from Topix.neten-usCopyright 2006, Topix.netTopix.net
http://www.topix.net/
http://www.topix.net/pics/logo4.gifGannett Reportedly Mulling Tribune Bid
http://topix.net/r/0l1Qq8DEtErajq5wDAIHZ0RavmEQ=2BIyZGBfGjcVwyQpW0DFdgUcy=2FtbxGNgMtYEdbU7ucVOR=2Bw2Bu6K4EDvt9=2B7ILEWB6Q5Zxy64f9JxkGU92am=2FLdMjb=2FCxbmfNuBQX6
Comment]]>The Associated Press on Topix.netMon, 13 Nov 2006 15:50:44 GMTeQE3vmbXGCzvaHn0deSSyAJournalism - Topix.netUse the text input below to search Topix.netq
http://www.topix.net/search/
EOF
# TEST
is ($rss->{textinput}->{link}, "http://www.topix.net/search/",
"Testing for textinput link"
);
# TEST
is ($rss->{channel}->{link}, "http://www.topix.net/news/journalism",
"Testing for channel link"
);
}
{
my $rss = XML::RSS->new();
$rss->parsefile(
File::Spec->catfile(
File::Spec->curdir(),
"examples",
"2.0",
"rss-2.0-sample-from-rssboard-multiple-skip-days-and-hours.xml"
)
);
# TEST
is_deeply(
$rss->{'skipHours'}->{'hour'},
[qw(0 1 2 22 23)],
"skipHours/hour is parsed into an array with the individual elements",
);
# TEST
is_deeply(
$rss->{'skipDays'}->{'day'},
[qw(Saturday Sunday)],
"skipDays/day is parsed into an array with indiv elements",
);
# TEST
is_deeply(
$rss->{'channel'}->{'category'},
[qw(Media Texas)],
"Multiple categories",
);
}
{
my $rss = XML::RSS->new();
$rss->parsefile(
File::Spec->catfile(
File::Spec->curdir(),
"t", "data", "2.0",
"sf-hs-with-pubDate.rss"
),
);
# TEST
is_deeply(
$rss->{'items'}->[0]->{'category'},
[qw(
mathml
mathematics
math
dos
jokes
tucan
ideas
mathventures
unixdoc
)],
"items/category is an array-ref",
);
}
{
my $rss = XML::RSS->new();
$rss->parsefile(
File::Spec->catfile(
File::Spec->curdir(),
"t", "data", "2.0",
"no-desc.rss",
),
);
# TEST
ok (!defined($rss->channel("description")),
"description is undefined if not present"
);
# TEST
ok (!defined($rss->channel("title")),
"title is undefined if not present",
);
}
{
my $rss = XML::RSS->new();
$rss->parsefile(
File::Spec->catfile(
File::Spec->curdir(),
"t", "data", "2.0",
"empty-desc.rss",
),
);
# TEST
is ($rss->channel("description"),
"",
"description is an empty string if an empty tag"
);
# TEST
is ($rss->channel("title"),
"",
"title is an empty string if an empty tasg",
);
}
{
my $rss = XML::RSS->new();
$rss->parsefile(
File::Spec->catfile(
File::Spec->curdir(),
qw(examples 2.0 flickr-rss-with-both-desc-and-media-desc.xml)
),
{ hashrefs_instead_of_strings => 1 },
);
# TEST
like ($rss->{'items'}->[0]->{'description'},
qr{\A\Q