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