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') };
24 BEGIN { use_ok('SDBM_File') };
25 BEGIN { use_ok('Fcntl') };
26 BEGIN { use_ok('charnames', qw{greek})};
28 use charnames qw{greek};
31 END { unlink <Op_dbmx*>; }
34 my $db1 = tie(%h1, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ;
36 ok $db1, "tied to SDBM_File";
38 eval { $db1->Filter_Push('encode' => 'blah') };
39 like $@, qr/^Encoding 'blah' is not available/, "push an illigal filter" ;
41 eval { $db1->Filter_Push('encode') };
42 is $@, '', "push an 'encode' filter (default to utf-8)" ;
46 no warnings 'uninitialized';
50 'alpha' => "\N{alpha}",
51 "\N{gamma}"=> "gamma",
59 'alpha' => "\N{alpha}",
61 "\N{gamma}"=> "gamma",
65 eval { $db1->Filter_Pop() };
66 is $@, '', "pop the 'utf8' filter" ;
68 eval { $db1->Filter_Push('encode' => 'iso-8859-16') };
69 is $@, '', "push an 'encode' filter (specify iso-8859-16)" ;
71 use charnames qw{:full};
74 'euro' => "\N{EURO SIGN}",
79 use warnings FATAL => 'untie';
81 is $@, '', "untie without inner references" ;
84 # read the dbm file without the filter
86 my $db2 = tie(%h2, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ;
88 ok $db2, "tied to SDBM_File";
92 'alpha' => "\xCE\xB1",
101 use warnings FATAL => 'untie';
103 is $@, '', "untie without inner references" ;