/[Sack]/trunk/t/Sack-Digest-BerkeleyDB.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/t/Sack-Digest-BerkeleyDB.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 85 - (show annotations)
Tue Sep 29 18:04:29 2009 UTC (14 years, 8 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1278 byte(s)
rename Sack::Digest to Sack::Digest::BerkeleyDB to indicate implementation
1 #!/usr/bin/perl
2
3 use Test::More tests => 29;
4 use Data::Dump qw(dump);
5
6 use lib 'lib';
7
8 BEGIN {
9 use_ok( 'Sack::Digest::BerkeleyDB' );
10 }
11
12 ok( my $o = Sack::Digest::BerkeleyDB->new( port => 0, clean => 1 ), 'new' );
13
14 my @full = qw( foo bar baz );
15
16 foreach my $full ( @full ) {
17
18 ok( my $nr = $o->to_int( $full ), "to_int $full" );
19 ok( $nr =~ m/^\d+$/, 'int' );
20
21 cmp_ok( $o->from_int( $nr ), 'eq', $full, "from_int $nr" );
22
23 }
24
25 cmp_ok( $o->from_int( 42 ), '==', 42, 'from_int missing' );
26
27 ok( $o->info, 'info' );
28
29 ok( $o->sync, 'sync' );
30
31 ok( $o->close, 'close' );
32
33 ok( $o->open, 'open' );
34
35 my $out = {
36 "CR#+" => { 1=>1, 2=>1, 3=>1, 4=>1, 5=>1 }
37 };
38
39 ok( my $full = $o->undigest_out( $out ), 'undigest_out' );
40 diag dump $full;
41 is_deeply( $full, { "CR#+" => { 4 => 1, 5 => 1, bar => 1, baz => 1, foo => 1 } }, 'undigested' );
42
43 foreach ( 1 .. $#full + 1 ) {
44 ok( my $undigested = $o->undigest_node_k_v( 0, 'CR#+' => $_ ), "undigest_node_k_v $_" );
45 diag "$_ -> $undigested";
46 cmp_ok( $undigested, 'eq', $full[$_-1], "undigested $_" )
47 }
48
49
50 ok( my $md5 = $o->lookup( nr_md5 => 1 ), 'lookup nr_md5' );
51 ok( my $nr = $o->lookup( md5_nr => $md5 ), 'lookup md5_nr' );
52 ok( my $full = $o->lookup( md5 => $md5 ), 'lookup md5' );
53 cmp_ok( $nr, '==', 1, 'nr' );
54
55 ok( $o->clean, 'clean' );
56

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26