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
|
use Test::More;
if (eval "use Devel::Size qw[total_size]; 1") {
plan tests => 1;
} else {
plan skip_all => "Devel::Size required for testing memory";
}
use ExtUtils::testlib;
use Crypt::GCrypt;
my $c = Crypt::GCrypt->new(
type => 'cipher',
algorithm => 'aes',
mode => 'cbc',
padding => 'null'
);
$c->start('encrypting');
$c->setkey("the key, the key");
my $fp = total_size($c);
my $e;
for (1..50) {
print "$_\n";
$e .= $c->encrypt('plain text' x 4);
}
$e .= $c->finish;
my $fp2 = total_size($c);
ok($fp == $fp2, 'constant memory allocation');
|