Tagged 0.99_01
[dbsrgits/DBM-Deep.git] / t / 02_hash.t
index d913e03..0bd49a7 100644 (file)
@@ -2,7 +2,7 @@
 # DBM::Deep Test
 ##
 use strict;
-use Test::More tests => 36;
+use Test::More tests => 38;
 use Test::Exception;
 use t::common qw( new_fh );
 
@@ -18,7 +18,6 @@ $db->{key1} = "value1";
 is( $db->get("key1"), "value1", "get() works with hash assignment" );
 is( $db->fetch("key1"), "value1", "... fetch() works with hash assignment" );
 is( $db->{key1}, "value1", "... and hash-access also works" );
-
 $db->put("key2", undef);
 is( $db->get("key2"), undef, "get() works with put()" );
 is( $db->fetch("key2"), undef, "... fetch() works with put()" );
@@ -44,6 +43,7 @@ ok( !exists $db->{key4}, "And key4 doesn't exists anymore" );
 ##
 # count keys
 ##
+
 is( scalar keys %$db, 3, "keys() works against tied hash" );
 
 ##
@@ -51,7 +51,7 @@ is( scalar keys %$db, 3, "keys() works against tied hash" );
 ##
 my $temphash = {};
 while ( my ($key, $value) = each %$db ) {
-       $temphash->{$key} = $value;
+    $temphash->{$key} = $value;
 }
 
 is( $temphash->{key1}, 'value1', "First key copied successfully using tied interface" );
@@ -61,8 +61,8 @@ is( $temphash->{key3}, 'value3', "Third key copied successfully" );
 $temphash = {};
 my $key = $db->first_key();
 while ($key) {
-       $temphash->{$key} = $db->get($key);
-       $key = $db->next_key($key);
+    $temphash->{$key} = $db->get($key);
+    $key = $db->next_key($key);
 }
 
 is( $temphash->{key1}, 'value1', "First key copied successfully using OO interface" );
@@ -75,6 +75,8 @@ is( $temphash->{key3}, 'value3', "Third key copied successfully" );
 is( delete $db->{key2}, undef, "delete through tied inteface works" );
 is( $db->delete("key1"), 'value1', "delete through OO inteface works" );
 is( $db->{key3}, 'value3', "The other key is still there" );
+ok( !exists $db->{key1}, "key1 doesn't exist" );
+ok( !exists $db->{key2}, "key2 doesn't exist" );
 
 is( scalar keys %$db, 1, "After deleting two keys, 1 remains" );
 
@@ -120,9 +122,9 @@ my $first_key = $db->first_key();
 my $next_key = $db->next_key($first_key);
 
 ok(
-       (($first_key eq "key1") || ($first_key eq "key2")) && 
-       (($next_key eq "key1") || ($next_key eq "key2")) && 
-       ($first_key ne $next_key)
+    (($first_key eq "key1") || ($first_key eq "key2")) && 
+    (($next_key eq "key1") || ($next_key eq "key2")) && 
+    ($first_key ne $next_key)
     ,"keys() still works if you replace long values with shorter ones"
 );