eff10b5d302e2cc214222a1a75ab10ba86f6724f
[dbsrgits/DBM-Deep.git] / t / 10_largekeys.t
1 ##
2 # DBM::Deep Test
3 ##
4 use strict;
5 use Test::More tests => 14;
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(
12         file => $filename,
13 );
14
15 ##
16 # large keys
17 ##
18 my $key1 = "Now is the time for all good men to come to the aid of their country." x 100;
19 my $key2 = "The quick brown fox jumped over the lazy, sleeping dog." x 1000;
20 my $key3 = "Lorem dolor ipsum latinum suckum causum Ium cannotum rememberum squatum." x 1000;
21
22 $db->put($key1, "value1");
23 $db->store($key2, "value2");
24 $db->{$key3} = "value3";
25
26 is( $db->{$key1}, 'value1', "Hash retrieval of put()" );
27 is( $db->{$key2}, 'value2', "Hash retrieval of store()" );
28 is( $db->{$key3}, 'value3', "Hash retrieval of hashstore" );
29 is( $db->get($key1), 'value1', "get() retrieval of put()" );
30 is( $db->get($key2), 'value2', "get() retrieval of store()" );
31 is( $db->get($key3), 'value3', "get() retrieval of hashstore" );
32 is( $db->fetch($key1), 'value1', "fetch() retrieval of put()" );
33 is( $db->fetch($key2), 'value2', "fetch() retrieval of store()" );
34 is( $db->fetch($key3), 'value3', "fetch() retrieval of hashstore" );
35
36 my $test_key = $db->first_key();
37 ok(
38         ($test_key eq $key1) || 
39         ($test_key eq $key2) || 
40         ($test_key eq $key3)
41 );
42
43 $test_key = $db->next_key($test_key);
44 ok(
45         ($test_key eq $key1) || 
46         ($test_key eq $key2) || 
47         ($test_key eq $key3)
48 );
49
50 $test_key = $db->next_key($test_key);
51 ok(
52         ($test_key eq $key1) || 
53         ($test_key eq $key2) || 
54         ($test_key eq $key3)
55 );
56
57 $test_key = $db->next_key($test_key);
58 ok( !$test_key );