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