Skip to content

Commit

Permalink
Adding tests for ::Generator->_files, ...->total_size, and ..->_count…
Browse files Browse the repository at this point in the history
…_files
  • Loading branch information
sanko committed Sep 16, 2010
1 parent 3aca9ed commit cd4f556
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion t/10000_by_class/Net/BitTorrent/Torrent/Generator.t
Expand Up @@ -33,7 +33,7 @@ package t::10000_by_class::Net::BitTorrent::Torrent::Generator;
explain 'Metadata now looks like...', $s->{'torrent'};
}

sub _001_comment : Test( 4 ) {
sub api_comment : Test( 4 ) {
my $s = shift;
is $s->{'torrent'}->comment, undef, 'default comment is undef';
ok !$s->{'torrent'}->_has_comment, '_has_comment is false';
Expand All @@ -42,6 +42,29 @@ package t::10000_by_class::Net::BitTorrent::Torrent::Generator;
is $s->{'torrent'}->comment, 'See credit.txt for attributions.',
'comment is correct';
}
{

sub _files {
['./t/90000_data/96000_data/96020_miniswarm_seed/1291672777_30adc6a421_o.jpg',
'./t/90000_data/96000_data/96020_miniswarm_seed/2183742557_5c9a91727d_m.jpg',
'./t/90000_data/96000_data/96020_miniswarm_seed/credit.txt'
];
}

sub api___files : Test( 3 ) {
my $s = shift;
is_deeply $s->{'torrent'}->files, $s->_files,
'list of files is correct';
is $s->{'torrent'}->_count_files, scalar(@{$s->_files}),
'_count_files is correct';
{
my $expected;
for my $file (@{$s->_files}) { $expected += -s $file }
is $s->{'torrent'}->total_size, $expected,
'total_size is correct'
}
}
}

#
#$ENV{'TEST_VERBOSE'}++;
Expand Down

0 comments on commit cd4f556

Please sign in to comment.