File: 10_largekeys.t

package info (click to toggle)
libdbm-deep-perl 2.0008-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 884 kB
  • sloc: perl: 7,383; sql: 36
file content (61 lines) | stat: -rw-r--r-- 1,855 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use strict;
use warnings FATAL => 'all';

use Test::More;
use t::common qw( new_dbm );

use_ok( 'DBM::Deep' );

my $dbm_factory = new_dbm();
while ( my $dbm_maker = $dbm_factory->() ) {
    my $db = $dbm_maker->();

    ##
    # large keys
    ##
    my $key1 = "Now is the time for all good men to come to the aid of their country." x 100;
    my $key2 = "The quick brown fox jumped over the lazy, sleeping dog." x 1000;
    my $key3 = "Lorem dolor ipsum latinum suckum causum Ium cannotum rememberum squatum." x 1000;

    $db->put($key1, "value1");
    $db->store($key2, "value2");
    $db->{$key3} = "value3";

    is( $db->{$key1}, 'value1', "Hash retrieval of put()" );
    is( $db->{$key2}, 'value2', "Hash retrieval of store()" );
    is( $db->{$key3}, 'value3', "Hash retrieval of hashstore" );
    is( $db->get($key1), 'value1', "get() retrieval of put()" );
    is( $db->get($key2), 'value2', "get() retrieval of store()" );
    is( $db->get($key3), 'value3', "get() retrieval of hashstore" );
    is( $db->fetch($key1), 'value1', "fetch() retrieval of put()" );
    is( $db->fetch($key2), 'value2', "fetch() retrieval of store()" );
    is( $db->fetch($key3), 'value3', "fetch() retrieval of hashstore" );

    my $test_key = $db->first_key();
    ok(
        ($test_key eq $key1) || 
        ($test_key eq $key2) || 
        ($test_key eq $key3),
        "First key found",
    );

    $test_key = $db->next_key($test_key);
    ok(
        ($test_key eq $key1) || 
        ($test_key eq $key2) || 
        ($test_key eq $key3),
        "Second key found",
    );

    $test_key = $db->next_key($test_key);
    ok(
        ($test_key eq $key1) || 
        ($test_key eq $key2) || 
        ($test_key eq $key3),
        "Third key found",
    );

    $test_key = $db->next_key($test_key);
    ok( !$test_key, "No fourth key" );
}
done_testing;