Debian lenny version packages
[pkg-perl] / deb-src / libio-compress-base-perl / libio-compress-base-perl-2.012 / t / compress / any.pl
1
2 use lib 't';
3  
4 use strict;
5 use warnings;
6 use bytes;
7
8 use Test::More ;
9 use CompTestUtils;
10
11 BEGIN {
12     # use Test::NoWarnings, if available
13     my $extra = 0 ;
14     $extra = 1
15         if eval { require Test::NoWarnings ;  import Test::NoWarnings; 1 };
16
17     plan tests => 48 + $extra ;
18
19 }
20
21 sub 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" ;
38             my $string = "some text" x 100 ;
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
57             {
58                 my $unc = new $AnyConstruct $input, Transparent => $trans,
59                                            RawInflate => 1,
60                                            Append => 1  ;
61
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;
72
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             }
94         }
95     }
96 }
97
98 1;