Commit | Line | Data |
ffed8b01 |
1 | ## |
2 | # DBM::Deep Test |
3 | ## |
4 | use strict; |
5 | use Test::More tests => 5; |
6 | |
7 | use_ok( 'DBM::Deep' ); |
8 | |
9 | unlink "t/test.db"; |
10 | my $db = DBM::Deep->new( "t/test.db" ); |
11 | if ($db->error()) { |
12 | die "ERROR: " . $db->error(); |
13 | } |
14 | |
15 | unlink "t/test2.db"; |
16 | my $db2 = DBM::Deep->new( "t/test2.db" ); |
17 | if ($db2->error()) { |
18 | die "ERROR: " . $db2->error(); |
19 | } |
20 | |
21 | ## |
22 | # Create structure in $db |
23 | ## |
24 | $db->import( |
25 | hash1 => { |
26 | subkey1 => "subvalue1", |
27 | subkey2 => "subvalue2" |
28 | } |
29 | ); |
30 | |
31 | is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" ); |
32 | is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" ); |
33 | |
34 | ## |
35 | # Cross-ref nested hash accross DB objects |
36 | ## |
37 | $db2->{copy} = $db->{hash1}; |
38 | |
39 | ## |
40 | # close, delete $db |
41 | ## |
42 | undef $db; |
43 | unlink "t/test.db"; |
44 | |
45 | ## |
46 | # Make sure $db2 has copy of $db's hash structure |
47 | ## |
48 | is( $db2->{copy}{subkey1}, 'subvalue1', "Value copied correctly" ); |
49 | is( $db2->{copy}{subkey2}, 'subvalue2', "Value copied correctly" ); |