Finished most of the renamings and updated Changes to reflect the new API
[dbsrgits/DBM-Deep.git] / t / 17_import.t
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" );
11 if ($db->error()) {
12         die "ERROR: " . $db->error();
13 }
14
15 ##
16 # Create structure in memory
17 ##
18 my $struct = {
19         key1 => "value1",
20         key2 => "value2",
21         array1 => [ "elem0", "elem1", "elem2" ],
22         hash1 => {
23                 subkey1 => "subvalue1",
24                 subkey2 => "subvalue2"
25         }
26 };
27
28 ##
29 # Import entire thing
30 ##
31 $db->import( $struct );
32 undef $struct;
33
34 ##
35 # Make sure everything is there
36 ##
37 ok(
38         ($db->{key1} eq "value1") && 
39         ($db->{key2} eq "value2") && 
40         ($db->{array1} && 
41                 ($db->{array1}->[0] eq "elem0") &&
42                 ($db->{array1}->[1] eq "elem1") && 
43                 ($db->{array1}->[2] eq "elem2")
44         ) && 
45         ($db->{hash1} &&
46                 ($db->{hash1}->{subkey1} eq "subvalue1") && 
47                 ($db->{hash1}->{subkey2} eq "subvalue2")
48         )
49 );