5 use Test::More tests => 13;
10 my $db = DBM::Deep->new( "t/test.db" );
12 die "ERROR: " . $db->error();
16 # Create structure in $db
20 subkey1 => "subvalue1",
21 subkey2 => "subvalue2",
24 subkey3 => 'subvalue3',
28 is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" );
29 is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" );
31 $db->{copy} = $db->{hash1};
33 is( $db->{copy}{subkey1}, 'subvalue1', "Value copied correctly" );
34 is( $db->{copy}{subkey2}, 'subvalue2', "Value copied correctly" );
36 $db->{copy}{subkey1} = "another value";
37 is( $db->{copy}{subkey1}, 'another value', "New value is set correctly" );
38 is( $db->{hash1}{subkey1}, 'another value', "Old value is set to the new one" );
40 is( scalar(keys %{$db->{hash1}}), 2, "Start with 2 keys in the original" );
41 is( scalar(keys %{$db->{copy}}), 2, "Start with 2 keys in the copy" );
43 delete $db->{copy}{subkey2};
45 is( scalar(keys %{$db->{copy}}), 1, "Now only have 1 key in the copy" );
46 is( scalar(keys %{$db->{hash1}}), 1, "... and only 1 key in the original" );
48 $db->{copy} = $db->{hash2};
49 is( $db->{copy}{subkey3}, 'subvalue3', "After the second copy, we're still good" );
55 my $db = DBM::Deep->new( 't/test2.db' );
57 $db->{foo} = [ 1 .. 3 ];
58 for ( 0 .. $max_keys ) {
59 $db->{'foo' . $_} = $db->{foo};
64 my $db = DBM::Deep->new( 't/test2.db' );
66 my $base_offset = $db->{foo}->_base_offset;
68 for ( 0 .. $max_keys ) {
70 unless ( $base_offset == $db->{'foo'.$_}->_base_offset ) {
74 is( $count, $max_keys, "We read $count keys" );