File: 16.t

package info (click to toggle)
libcache-fastmmap-perl 1.60-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 356 kB
  • sloc: ansic: 1,404; perl: 635; makefile: 7
file content (41 lines) | stat: -rw-r--r-- 769 bytes parent folder | download | duplicates (5)
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

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

use Test::More tests => 3;
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(
  init_file => 1,
  num_pages => 1,
  page_size => 2 ** 15,
);
ok( defined $FC );

my @d;

for (1 .. 20) {

  $FC->set($_, $d[$_]=$_) for 1 .. 100;

  for (1 .. 50) {
    $FC->remove($_*2);
    $d[$_*2] = undef;

    $FC->set($_, $_*2);
    $d[$_] = $_*2;

    for my $c (1 .. 100) {
      my $v = $FC->get($c);
      ($v || 0) == ($d[$c] || 0)
        || die "at offset $c, got $v expected $d[$c]";
    }
  }

}
ok(1, "ordering santity tests complete");