New data for Unicode on older versions, thanks to Nicholas
[p5sagit/p5-mst-13.2.git] / lib / DBM_Filter / t / int32.t
CommitLineData
0e9b1cbd 1
2use strict;
3use warnings;
4use Carp;
5
6require "dbm_filter_util.pl";
7
8use Test::More tests => 22;
9
10BEGIN { use_ok('DBM_Filter') };
e8ebc68a 11my $db_file;
12BEGIN {
13 use Config;
14 foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) {
15 if ($Config{extensions} =~ /\b$_\b/) {
16 $db_file = $_;
17 last;
18 }
19 }
20 use_ok($db_file);
21};
0e9b1cbd 22BEGIN { use_ok('Fcntl') };
23
24unlink <Op_dbmx*>;
25END { unlink <Op_dbmx*>; }
26
27my %h1 = () ;
e8ebc68a 28my $db1 = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ;
0e9b1cbd 29
e8ebc68a 30ok $db1, "tied to $db_file";
0e9b1cbd 31
32# store before adding the filter
33
34StoreData(\%h1,
35 {
36 1234 => 5678,
37 -3 => -5,
38 "22" => "88",
39 "-45" => "-88",
40 });
41
42VerifyData(\%h1,
43 {
44 1234 => 5678,
45 -3 => -5,
46 22 => 88,
47 -45 => -88,
48 });
49
50
51eval { $db1->Filter_Push('int32') };
52is $@, '', "push an 'int32' filter" ;
53
54{
55 no warnings 'uninitialized';
56 StoreData(\%h1,
57 {
58 undef() => undef(),
59 "400" => "500",
60 0 => 1,
61 1 => 0,
62 -47 => -6,
63 });
64
65}
66
67undef $db1;
68{
69 use warnings FATAL => 'untie';
70 eval { untie %h1 };
71 is $@, '', "untie without inner references" ;
72}
73
74# read the dbm file without the filter
75my %h2 = () ;
e8ebc68a 76my $db2 = tie(%h2, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ;
0e9b1cbd 77
e8ebc68a 78ok $db2, "tied to $db_file";
0e9b1cbd 79
80VerifyData(\%h2,
81 {
82 1234 => 5678,
83 -3 => -5,
84 22 => 88,
85 -45 => -88,
86
87 #undef() => undef(),
88 pack("i", 400) => pack("i", 500),
89 pack("i", 0) => pack("i", 1),
90 pack("i", 1) => pack("i", 0),
91 pack("i", -47) => pack("i", -6),
92 });
93
94undef $db2;
95{
96 use warnings FATAL => 'untie';
97 eval { untie %h2 };
98 is $@, '', "untie without inner references" ;
99}
100