New testing feature that allows specification of the workdir for the tests
[dbsrgits/DBM-Deep.git] / t / 17_import.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 ($fh, $filename) = new_fh();
11 my $db = DBM::Deep->new( $filename );
12
13 ##
14 # Create structure in memory
15 ##
16 my $struct = {
17         key1 => "value1",
18         key2 => "value2",
19         array1 => [ "elem0", "elem1", "elem2" ],
20         hash1 => {
21                 subkey1 => "subvalue1",
22                 subkey2 => "subvalue2"
23         }
24 };
25
26 ##
27 # Import entire thing
28 ##
29 $db->import( $struct );
30 undef $struct;
31
32 ##
33 # Make sure everything is there
34 ##
35 ok(
36         ($db->{key1} eq "value1") && 
37         ($db->{key2} eq "value2") && 
38         ($db->{array1} && 
39                 ($db->{array1}->[0] eq "elem0") &&
40                 ($db->{array1}->[1] eq "elem1") && 
41                 ($db->{array1}->[2] eq "elem2")
42         ) && 
43         ($db->{hash1} &&
44                 ($db->{hash1}->{subkey1} eq "subvalue1") && 
45                 ($db->{hash1}->{subkey2} eq "subvalue2")
46         )
47 );