IO::Compress::Zip
authorPaul Marquess <paul.marquess@btinternet.com>
Fri, 31 Mar 2006 09:48:36 +0000 (10:48 +0100)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 31 Mar 2006 12:10:57 +0000 (12:10 +0000)
From: "Paul Marquess" <paul.marquess@ntlworld.com>
Message-ID: <005201c6549f$e7374490$2405140a@myopwv.com>

p4raw-id: //depot/perl@27640

ext/Compress/IO/Zlib/t/105oneshot-zip-only.t

index 91d950e..aaf5bfc 100644 (file)
@@ -23,7 +23,7 @@ BEGIN {
     $extra = 1
         if eval { require Test::NoWarnings ;  import Test::NoWarnings; 1 };
 
-    plan tests => 95 + $extra ;
+    plan tests => 119 + $extra ;
 
     use_ok('IO::Compress::Zip', qw(zip $ZipError)) ;
     use_ok('IO::Uncompress::Unzip', qw(unzip $UnzipError)) ;
@@ -141,7 +141,7 @@ for my $stream (0, 1)
         my $lex = new LexFile my $file1;
 
         my $content = "hello ";
-        writeFile($file1, $content);
+        #writeFile($file1, $content);
 
         ok zip(\$content => $file1 , Store => !$store, Stream => $stream), " zip ok" 
             or diag $ZipError ;
@@ -171,5 +171,48 @@ for my $stream (0, 1)
     }
 }
 
+for my $stream (0, 1)
+{
+    for my $store (0, 1)
+    {
+        title "Stream $stream, Store $store";
+
+        my $file1;
+        my $file2;
+        my $zipfile;
+        my $lex = new LexFile $file1, $file2, $zipfile;
+
+        my $content1 = "hello ";
+        writeFile($file1, $content1);
+
+        my $content2 = "goodbye ";
+        writeFile($file2, $content2);
+
+        my %content = ( $file1 => $content1,
+                        $file2 => $content2,
+                      );
+
+        ok zip([$file1, $file2] => $zipfile , Store => !$store, Stream => $stream), " zip ok" 
+            or diag $ZipError ;
+
+        for my $file ($file1, $file2)
+        {
+            my $got ;
+            if ($stream && ! $store) {
+                #eval ' unzip($zipfile => \$got) ';
+                ok ! unzip($zipfile => \$got, Name => $file), "  unzip fails"; 
+                like $UnzipError, "/Streamed Stored content not supported/",
+                    "  Streamed Stored content not supported";
+                    next ;
+            }
+
+            ok unzip($zipfile => \$got, Name => $file), "  unzip $file ok"
+                or diag $UnzipError ;
+
+            is $got, $content{$file}, "  content ok";
+        }
+    }
+}
+
 # TODO add more error cases