Commit | Line | Data |
ffed8b01 |
1 | ## |
2 | # DBM::Deep Test |
3 | ## |
4 | use strict; |
5 | use Test::More tests => 2; |
6 | |
7 | use_ok( 'DBM::Deep' ); |
8 | |
9 | unlink "t/test.db"; |
10 | my $db = DBM::Deep->new( "t/test.db" ); |
ffed8b01 |
11 | |
12 | ## |
13 | # Create structure in DB |
14 | ## |
15 | $db->import( |
16 | key1 => "value1", |
17 | key2 => "value2", |
02776a7e |
18 | array1 => [ "elem0", "elem1", "elem2", { foo => 'bar' }, [ 5 ] ], |
ffed8b01 |
19 | hash1 => { |
20 | subkey1 => "subvalue1", |
02776a7e |
21 | subkey2 => "subvalue2", |
ffed8b01 |
22 | } |
23 | ); |
24 | |
25 | ## |
26 | # Export entire thing |
27 | ## |
28 | my $struct = $db->export(); |
29 | |
30 | ## |
31 | # close, delete file |
32 | ## |
33 | undef $db; |
34 | unlink "t/test.db"; |
35 | |
36 | ## |
37 | # Make sure everything is here, outside DB |
38 | ## |
39 | ok( |
40 | ($struct->{key1} eq "value1") && |
41 | ($struct->{key2} eq "value2") && |
42 | ($struct->{array1} && |
43 | ($struct->{array1}->[0] eq "elem0") && |
44 | ($struct->{array1}->[1] eq "elem1") && |
02776a7e |
45 | ($struct->{array1}->[2] eq "elem2") && |
46 | ($struct->{array1}->[3]{foo} eq "bar") && |
47 | ($struct->{array1}->[4][0] eq "5") |
ffed8b01 |
48 | ) && |
49 | ($struct->{hash1} && |
50 | ($struct->{hash1}->{subkey1} eq "subvalue1") && |
51 | ($struct->{hash1}->{subkey2} eq "subvalue2") |
52 | ) |
53 | ); |