Converted all relevant tests to use new_dbm instead of new_fh and all tests (except...
[dbsrgits/DBM-Deep.git] / t / 46_blist_reindex.t
1 # This test (and accompanying patch) was submitted by Father Chrysostomos (sprout@cpan.org)
2
3 use strict;
4 use warnings FATAL => 'all';
5
6 use Test::More;
7
8 use t::common qw( new_dbm );
9
10 use_ok( 'DBM::Deep' );
11
12 {
13     my $dbm_factory = new_dbm();
14     while ( my $dbm_maker = $dbm_factory->() ) {
15         my $db = $dbm_maker->();
16     
17         ok eval {
18             for ( # the checksums of all these begin with ^@:
19                 qw/ s340l 1970 thronos /,
20                 "\320\277\320\276\320\262\320\265\320\273\320\265\320\275".
21                 "\320\275\320\276\320\265", qw/ mr094 despite
22                 geographically binding bed handmaiden infer lela infranarii
23                 lxv evtropia recognizes maladies /
24             ) {
25                 $db->{$_} = undef;
26             }
27             1;
28         }, '2 indices can be created at once';
29         
30         is_deeply [sort keys %$db], [ sort
31             qw/ s340l 1970 thronos /,
32             "\320\277\320\276\320\262\320\265\320\273\320\265\320\275".
33             "\320\275\320\276\320\265", qw/ mr094 despite
34             geographically binding bed handmaiden infer lela infranarii
35             lxv evtropia recognizes maladies /
36         ], 'and the keys were stored correctly';
37     }
38 }
39
40 {
41     my $dbm_factory = new_dbm();
42     while ( my $dbm_maker = $dbm_factory->() ) {
43         my $db = $dbm_maker->();
44     
45         ok eval {
46             for ( # the checksums of all these begin with ^@^@^@:
47                 qw/ dzqtz aqkdqz cxzysd czclmy ktajsi kvlybo kyxowd lvlsda
48                     lyzfdi mbethb mcoqeq VMPJC ATZMZZ AXXJDX BXUUFN EIVTII
49                     FMOKOI HITVDG JSSJSZ JXQPFK LCVVXW /
50             ) {
51                 $db->{$_} = undef;
52             }
53             1;
54         }, 'multiple nested indices can be created at once';
55         
56         is_deeply [sort keys %$db], [ sort
57             qw/ dzqtz aqkdqz cxzysd czclmy ktajsi kvlybo kyxowd lvlsda
58                 lyzfdi mbethb mcoqeq VMPJC ATZMZZ AXXJDX BXUUFN EIVTII
59                 FMOKOI HITVDG JSSJSZ JXQPFK LCVVXW /
60         ], 'and the keys were stored correctly';
61     }
62 }
63
64 done_testing;