summaryrefslogtreecommitdiff
path: root/ext/IO-Compress/t/002any-transparent.t
blob: bb26bbcac0af7e6c53bcbf47e90eb272fdd4579d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
BEGIN {
    if ($ENV{PERL_CORE}) {
        chdir 't' if -d 't';
        @INC = ("../lib", "lib/compress");
    }
}

use lib qw(t t/compress);
 
use strict;
use warnings;
use bytes;

use Test::More ;
use CompTestUtils;

BEGIN {
    # use Test::NoWarnings, if available
    my $extra = 0 ;
    $extra = 1
        if eval { require Test::NoWarnings ;  import Test::NoWarnings; 1 };

    plan tests => 15 + $extra ;

    use_ok('IO::Uncompress::AnyInflate', qw($AnyInflateError)) ;

}

{

    my $string = <<EOM;
This is not compressed data
EOM

    my $buffer = $string ;

    for my $file (0, 1)
    {
        title "AnyInflate with Non-compressed data (File $file)" ;

        my $lex = new LexFile my $output;
        my $input ;

        if ($file) {
            writeFile($output, $buffer);
            $input = $output;
        }
        else {
            $input = \$buffer;
        }


        my $unc ;
        my $keep = $buffer ;
        $unc = new IO::Uncompress::AnyInflate $input, -Transparent => 0 ;
        ok ! $unc,"  no AnyInflate object when -Transparent => 0" ;
        is $buffer, $keep ;

        $buffer = $keep ;
        $unc = new IO::Uncompress::AnyInflate \$buffer, -Transparent => 1 ;
        ok $unc, "  AnyInflate object when -Transparent => 1"  ;

        my $uncomp ;
        ok $unc->read($uncomp) > 0 ;
        ok $unc->eof() ;
        #ok $unc->type eq $Type;

        is $uncomp, $string ;
    }
}

1;