New testing feature that allows specification of the workdir for the tests
[dbsrgits/DBM-Deep.git] / t / 18_export.t
1 ##
2 # DBM::Deep Test
3 ##
4 use strict;
5 use Test::More tests => 2;
6 use t::common qw( new_fh );
7
8 use_ok( 'DBM::Deep' );
9
10 my $struct;
11 {
12     my ($fh, $filename) = new_fh();
13     my $db = DBM::Deep->new( $filename );
14
15     ##
16     # Create structure in DB
17     ##
18     $db->import(
19         key1 => "value1",
20         key2 => "value2",
21         array1 => [ "elem0", "elem1", "elem2", { foo => 'bar' }, [ 5 ] ],
22         hash1 => {
23             subkey1 => "subvalue1",
24             subkey2 => "subvalue2",
25         }
26     );
27
28     ##
29     # Export entire thing
30     ##
31     $struct = $db->export();
32 }
33
34 ##
35 # Make sure everything is here, outside DB
36 ##
37 ok(
38         ($struct->{key1} eq "value1") && 
39         ($struct->{key2} eq "value2") && 
40         ($struct->{array1} && 
41                 ($struct->{array1}->[0] eq "elem0") &&
42                 ($struct->{array1}->[1] eq "elem1") && 
43                 ($struct->{array1}->[2] eq "elem2") &&
44                 ($struct->{array1}->[3]{foo} eq "bar") &&
45                 ($struct->{array1}->[4][0] eq "5")
46         ) && 
47         ($struct->{hash1} &&
48                 ($struct->{hash1}->{subkey1} eq "subvalue1") && 
49                 ($struct->{hash1}->{subkey2} eq "subvalue2")
50         )
51 );