Don't require to have at least DB_File or *DBM_File
[p5sagit/p5-mst-13.2.git] / t / lib / compress / any.pl
CommitLineData
1a6a8453 1
2use lib 't';
3
4use strict;
5use warnings;
6use bytes;
7
8use Test::More ;
25f0751f 9use CompTestUtils;
1a6a8453 10
11BEGIN {
12 # use Test::NoWarnings, if available
13 my $extra = 0 ;
14 $extra = 1
15 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
16
6ecef415 17 plan tests => 48 + $extra ;
1a6a8453 18
19}
20
21sub run
22{
23 my $CompressClass = identify();
24 my $AnyClass = getClass();
25 my $UncompressClass = getInverse($CompressClass);
26 my $Error = getErrorRef($CompressClass);
27 my $UnError = getErrorRef($UncompressClass);
28
29 my $AnyConstruct = "IO::Uncompress::${AnyClass}" ;
30 no strict 'refs';
31 my $AnyError = \${ "IO::Uncompress::${AnyClass}::${AnyClass}Error" };
32
33 for my $trans ( 0, 1 )
34 {
35 for my $file ( 0, 1 )
36 {
37 title "$AnyClass(Transparent => $trans, File=>$file) with $CompressClass" ;
6ecef415 38 my $string = "some text" x 100 ;
1a6a8453 39
40 my $buffer ;
41 my $x = new $CompressClass(\$buffer) ;
42 ok $x, " create $CompressClass object" ;
43 ok $x->write($string), " write to object" ;
44 ok $x->close, " close ok" ;
45
46 my $lex = new LexFile my $output;
47 my $input ;
48
49 if ($file) {
50 writeFile($output, $buffer);
51 $input = $output;
52 }
53 else {
54 $input = \$buffer;
55 }
56
6ecef415 57 {
58 my $unc = new $AnyConstruct $input, Transparent => $trans,
59 RawInflate => 1,
60 Append => 1 ;
1a6a8453 61
6ecef415 62 ok $unc, " Created $AnyClass object"
63 or print "# $$AnyError\n";
64 my $uncomp ;
65 1 while $unc->read($uncomp) > 0 ;
66 #ok $unc->read($uncomp) > 0
67 # or print "# $$AnyError\n";
68 my $y;
69 is $unc->read($y, 1), 0, " at eof" ;
70 ok $unc->eof(), " at eof" ;
71 #ok $unc->type eq $Type;
1a6a8453 72
6ecef415 73 is $uncomp, $string, " expected output" ;
74 }
75
76 {
77 my $unc = new $AnyConstruct $input, Transparent => $trans,
78 RawInflate => 1,
79 Append => 1 ;
80
81 ok $unc, " Created $AnyClass object"
82 or print "# $$AnyError\n";
83 my $uncomp ;
84 1 while $unc->read($uncomp, 100) > 0 ;
85 #ok $unc->read($uncomp) > 0
86 # or print "# $$AnyError\n";
87 my $y;
88 is $unc->read($y, 1), 0, " at eof" ;
89 ok $unc->eof(), " at eof" ;
90 #ok $unc->type eq $Type;
91
92 is $uncomp, $string, " expected output" ;
93 }
1a6a8453 94 }
95 }
96}
97
981;