6 BEGIN { plan tests => 13 }
16 my $db = new DBM::Deep(
20 die "ERROR: " . $db->error();
26 DBM::Deep::set_digest( \&my_digest, 8 );
31 $db->{key1} = "value1";
32 ok( $db->{key1} eq "value1" );
34 $db->put("key2", "value2");
35 ok( $db->get("key2") eq "value2" );
40 ok( $db->exists("key1") );
41 ok( exists $db->{key2} );
46 ok( scalar keys %$db == 2 );
52 while ( my ($key, $value) = each %$db ) {
53 $temphash->{$key} = $value;
56 ok( ($temphash->{key1} eq "value1") && ($temphash->{key2} eq "value2") );
59 my $key = $db->first_key();
61 $temphash->{$key} = $db->get($key);
62 $key = $db->next_key($key);
65 ok( ($temphash->{key1} eq "value1") && ($temphash->{key2} eq "value2") );
70 ok( delete $db->{key1} );
71 ok( $db->delete("key2") );
73 ok( scalar keys %$db == 0 );
78 $db->put("another", "value");
81 ok( scalar keys %$db == 0 );
86 $db->put("key1", "value1");
87 $db->put("key1", "value2");
89 ok( $db->get("key1") eq "value2" );
91 $db->put("key1", "value222222222222222222222222");
93 ok( $db->get("key1") eq "value222222222222222222222222" );
96 # close, delete file, exit
104 # Warning: This digest function is for testing ONLY
105 # It is NOT intended for actual use
110 for (my $k=0; $k<length($key); $k++) {
111 $num += ord( substr($key, $k, 1) );
114 return sprintf("%00000008d", $num);