File: 05-size.t

package info (click to toggle)
libcrypt-gcrypt-perl 1.26-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: perl: 237; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 665 bytes parent folder | download | duplicates (6)
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');