Merged with master and am ready to merge back
[dbsrgits/DBM-Deep.git] / t / 46_blist_reindex.t
CommitLineData
5a70a6c0 1# This test (and accompanying patch) was submitted by Father Chrysostomos (sprout@cpan.org)
2
5a70a6c0 3use strict;
4use warnings FATAL => 'all';
5
0e3e3555 6use Test::More;
5a70a6c0 7
0e3e3555 8use t::common qw( new_dbm );
5a70a6c0 9
10use_ok( 'DBM::Deep' );
11
12{
0e3e3555 13 my $dbm_factory = new_dbm();
14 while ( my $dbm_maker = $dbm_factory->() ) {
15 my $db = $dbm_maker->();
5a70a6c0 16
0e3e3555 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
5a70a6c0 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 /
0e3e3555 36 ], 'and the keys were stored correctly';
37 }
5a70a6c0 38}
39
40{
0e3e3555 41 my $dbm_factory = new_dbm();
42 while ( my $dbm_maker = $dbm_factory->() ) {
43 my $db = $dbm_maker->();
5a70a6c0 44
0e3e3555 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
5a70a6c0 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 /
0e3e3555 60 ], 'and the keys were stored correctly';
61 }
5a70a6c0 62}
63
0e3e3555 64done_testing;