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
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 105;
BEGIN { use_ok('XML::RSS::Feed') }
my $max_headlines = 5;
my $iterations = 100;
my $title = "This is a test 1";
my $url = "http://www.jbisbee.com/test/url/1";
cmp_ok( $max_headlines, "<", $iterations,
"Max headlines must be less than iterations" );
my $feed = XML::RSS::Feed->new(
url => "http://www.jbisbee.com/rdf/",
name => 'jbisbee',
max_headlines => $max_headlines,
);
isa_ok( $feed, 'XML::RSS::Feed' );
$feed->pre_process();
my @headlines = ();
for my $i ( 1 .. $iterations ) {
my %hash = (
headline => ++$title,
url => ++$url,
);
unshift @headlines, $hash{headline};
$feed->create_headline(%hash);
cmp_ok( $feed->num_headlines, '<=', $max_headlines,
"Verify max_headlines $i" );
}
$feed->post_process();
cmp_ok( $feed->num_headlines, '==', $max_headlines, "Verify max_headlines" );
@headlines = splice( @headlines, 0, $max_headlines );
my @headlines2 = map { $_->headline } $feed->headlines;
ok( eq_array( \@headlines, \@headlines2 ),
"Comparing before and after headlines"
);
|