File: 14.t

package info (click to toggle)
libcache-fastmmap-perl 1.58-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 356 kB
  • sloc: ansic: 1,399; perl: 628; makefile: 7
file content (42 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (7)
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

#########################

use Test::More tests => 110;
BEGIN { use_ok('Cache::FastMmap') };
use strict;

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

my $FC = Cache::FastMmap->new(
  enable_stats => 1
);

ok( defined $FC );

ok( !defined $FC->get("a") );
$FC->set("a", "b");
ok( $FC->get("a") eq "b" );

# Get 100 times
for (1 .. 100) {
  ok( $FC->get("a") eq "b" );
}

my ($nreads, $nreadhits) = $FC->get_statistics();

cmp_ok( $nreads, '==', 102 );
cmp_ok( $nreadhits, '==', 101 );

($nreads, $nreadhits) = $FC->get_statistics(1);

cmp_ok( $nreads, '==', 102 );
cmp_ok( $nreadhits, '==', 101 );

($nreads, $nreadhits) = $FC->get_statistics(1);

cmp_ok( $nreads, '==', 0 );
cmp_ok( $nreadhits, '==', 0 );