10 eval { require Encode; };
13 print "1..0 # Skip: Encode is not available\n";
19 require "dbm_filter_util.pl";
21 use Test::More tests => 26;
23 BEGIN { use_ok('DBM_Filter') };
27 foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) {
28 if ($Config{extensions} =~ /\b$_\b/) {
35 BEGIN { use_ok('Fcntl') };
36 BEGIN { use_ok('charnames', qw{greek})};
38 use charnames qw{greek};
41 END { unlink <Op_dbmx*>; }
44 my $db1 = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ;
46 ok $db1, "tied to $db_file";
48 eval { $db1->Filter_Push('encode' => 'blah') };
49 like $@, qr/^Encoding 'blah' is not available/, "push an illegal filter" ;
51 eval { $db1->Filter_Push('encode') };
52 is $@, '', "push an 'encode' filter (default to utf-8)" ;
56 no warnings 'uninitialized';
60 'alpha' => "\N{alpha}",
61 "\N{gamma}"=> "gamma",
69 'alpha' => "\N{alpha}",
71 "\N{gamma}"=> "gamma",
75 eval { $db1->Filter_Pop() };
76 is $@, '', "pop the 'utf8' filter" ;
78 eval { $db1->Filter_Push('encode' => 'iso-8859-16') };
79 is $@, '', "push an 'encode' filter (specify iso-8859-16)" ;
81 use charnames qw{:full};
84 'euro' => "\N{EURO SIGN}",
89 use warnings FATAL => 'untie';
91 is $@, '', "untie without inner references" ;
94 # read the dbm file without the filter
96 my $db2 = tie(%h2, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ;
98 ok $db2, "tied to $db_file";
100 if (ord('A') == 193) { # EBCDIC.
103 'alpha' => "\xB4\x58",
104 'beta' => "\xB4\x59",
105 "\xB4\x62"=> "gamma",
106 "\x65\x75\x72\x6F" => "\xA4",
112 'alpha' => "\xCE\xB1",
113 'beta' => "\xCE\xB2",
114 "\xCE\xB3"=> "gamma",
122 use warnings FATAL => 'untie';
124 is $@, '', "untie without inner references" ;