1BEGIN { 2 if ($ENV{PERL_CORE}) { 3 chdir 't' if -d 't'; 4 @INC = ("../lib", "lib/compress"); 5 } 6} 7 8use lib qw(t t/compress); 9use strict; 10use warnings; 11use bytes; 12 13use Test::More ; 14use CompTestUtils; 15 16BEGIN { 17 plan(skip_all => "oneshot needs Perl 5.005 or better - you have Perl $]" ) 18 if $] < 5.005 ; 19 20 plan skip_all => "Lengthy Tests Disabled\n" . 21 "set COMPRESS_ZLIB_RUN_ALL or COMPRESS_ZLIB_RUN_MOST to run this test suite" 22 unless defined $ENV{COMPRESS_ZLIB_RUN_ALL} or defined $ENV{COMPRESS_ZLIB_RUN_MOST}; 23 24 plan(skip_all => "IO::Compress::Bzip2 not available" ) 25 unless eval { require IO::Compress::Bzip2; 26 require IO::Uncompress::Bunzip2; 27 1 28 } ; 29 30 # use Test::NoWarnings, if available 31 my $extra = 0 ; 32 $extra = 1 33 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; 34 35 plan tests => 1058 + $extra ; 36 37 use_ok('IO::Compress::Zip', qw(:all)) ; 38 use_ok('IO::Uncompress::Unzip', qw(unzip $UnzipError)) ; 39} 40 41my @contents; 42my $content = "x" x 1025; 43$content .= "\x50" ; 44 45push @contents, $content ; 46 47$content .= "y" x 321 ; 48$content .= "\x50\x4b" ; 49push @contents, $content ; 50 51$content .= "z" x 21 ; 52$content .= "\x50\x4b\x07" . "a" x 73 ; 53push @contents, $content ; 54 55$content .= "a" x 73 ; 56$content .= "\x50\x4b\x07\x08" ; 57push @contents, $content ; 58 59$content .= "b" x 102 ; 60$content .= "\x50\x4b\x07\x08" . "\x50\x4b\x07\x08" ; 61push @contents, $content ; 62 63$content .= "c" x 102 ; 64push @contents, $content ; 65 66 67my $index = 0; 68for $content (@contents) 69{ 70 ++ $index ; 71 my $contentLen = length $content ; 72 73 74 for my $stream (0, 1) 75 { 76 for my $zip64 (0, 1) 77 { 78 for my $blockSize (1 .. 7, $contentLen, $contentLen-1, $contentLen +1, 16*1024) 79 { 80 title "Index $index, Stream $stream, Zip64 $zip64, BlockSize $blockSize"; 81 82 my $crc = Compress::Raw::Zlib::crc32($content); 83 $content .= "\x50\x4b\x07\x08" . pack("V", $crc) . "b" x 53 ; 84 85 my $zipped ; 86 87 ok zip(\$content => \$zipped , Method => ZIP_CM_STORE, 88 Zip64 => $zip64, 89 Stream => $stream), " zip ok" 90 or diag $ZipError ; 91 92 my $got ; 93 ok unzip(\$zipped => \$got, BlockSize => $blockSize), " unzip ok" 94 or diag $UnzipError ; 95 96 is $got, $content, " content ok"; 97 98 } 99 } 100 } 101} 102 103