added test for freespace management
[dbsrgits/DBM-Deep.git] / t / 16_circular.t
CommitLineData
ffed8b01 1##
2# DBM::Deep Test
3##
4use strict;
5use Test::More tests => 13;
6
7use_ok( 'DBM::Deep' );
8
9unlink "t/test.db";
10my $db = DBM::Deep->new( "t/test.db" );
ffed8b01 11
12##
13# put/get simple keys
14##
15$db->{key1} = "value1";
16$db->{key2} = "value2";
17
18##
19# Insert circular reference
20##
21$db->{circle} = $db;
22
23##
24# Make sure keys exist in both places
25##
26is( $db->{key1}, 'value1', "The value is there directly" );
27is( $db->{circle}{key1}, 'value1', "The value is there in one loop of the circle" );
28is( $db->{circle}{circle}{key1}, 'value1', "The value is there in two loops of the circle" );
29is( $db->{circle}{circle}{circle}{key1}, 'value1', "The value is there in three loops of the circle" );
30
31##
32# Make sure changes are reflected in both places
33##
34$db->{key1} = "another value";
35
36is( $db->{key1}, 'another value', "The value is there directly" );
37is( $db->{circle}{key1}, 'another value', "The value is there in one loop of the circle" );
38is( $db->{circle}{circle}{key1}, 'another value', "The value is there in two loops of the circle" );
39is( $db->{circle}{circle}{circle}{key1}, 'another value', "The value is there in three loops of the circle" );
40
41$db->{circle}{circle}{circle}{circle}{key1} = "circles";
42
43is( $db->{key1}, 'circles', "The value is there directly" );
44is( $db->{circle}{key1}, 'circles', "The value is there in one loop of the circle" );
45is( $db->{circle}{circle}{key1}, 'circles', "The value is there in two loops of the circle" );
46is( $db->{circle}{circle}{circle}{key1}, 'circles', "The value is there in three loops of the circle" );