Created
November 6, 2010 15:19
-
-
Save wchristian/665481 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
package avg_size_calculation; | |
BEGIN { | |
use Cwd; | |
chdir '..' if getcwd =~ m@/t$@; | |
use lib '../lib'; | |
} | |
use Test::Most; | |
use lib 'lib'; | |
use TFX::DownloadTOFiles::File; | |
test_avg_size_calculation(); | |
done_testing; | |
exit; | |
sub test_avg_size_calculation { | |
my @get; | |
no warnings 'redefine'; | |
local *TFX::DownloadTOFiles::File::_get_size_tail_from_db = sub { @get }; | |
my $file = TFX::DownloadTOFiles::File->new( { db => { expected_size => 2 } } ); | |
@get = qw(); | |
is( $file->compute_average_size_of_tail, 2, 'average size with no previous sizes returns the expected size' ); | |
@get = qw( 5 5 5 5 5 ); | |
is( $file->compute_average_size_of_tail, 2, 'average size with too few previous sizes returns the expected size' ); | |
@get = qw( 5 5 5 5 5 5 ); | |
is( $file->compute_average_size_of_tail, 5, 'average size with enough previous sizes returns the average' ); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment