New testing feature that allows specification of the workdir for the tests
[dbsrgits/DBM-Deep.git] / t / 18_export.t
CommitLineData
ffed8b01 1##
2# DBM::Deep Test
3##
4use strict;
5use Test::More tests => 2;
fde3db1a 6use t::common qw( new_fh );
ffed8b01 7
8use_ok( 'DBM::Deep' );
9
2a81bf9e 10my $struct;
11{
fde3db1a 12 my ($fh, $filename) = new_fh();
2a81bf9e 13 my $db = DBM::Deep->new( $filename );
ffed8b01 14
2a81bf9e 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 );
ffed8b01 27
2a81bf9e 28 ##
29 # Export entire thing
30 ##
31 $struct = $db->export();
32}
ffed8b01 33
34##
35# Make sure everything is here, outside DB
36##
37ok(
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") &&
02776a7e 43 ($struct->{array1}->[2] eq "elem2") &&
44 ($struct->{array1}->[3]{foo} eq "bar") &&
45 ($struct->{array1}->[4][0] eq "5")
ffed8b01 46 ) &&
47 ($struct->{hash1} &&
48 ($struct->{hash1}->{subkey1} eq "subvalue1") &&
49 ($struct->{hash1}->{subkey2} eq "subvalue2")
50 )
51);