diff options
Diffstat (limited to 't/05_tree.t')
-rw-r--r-- | t/05_tree.t | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/t/05_tree.t b/t/05_tree.t new file mode 100644 index 0000000..91bc3f5 --- /dev/null +++ b/t/05_tree.t @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +use strict; + +use strict; + +BEGIN { + $| = 1; + $^W = 1; +} +use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); +use FileHandle; +use File::Spec; + +use Test::More tests => 6; +use t::common; + +use constant FILENAME => File::Spec->catfile(TESTDIR, 'testing.txt'); + +my $zip; +my @memberNames; + +sub makeZip { + my ($src, $dest, $pred) = @_; + $zip = Archive::Zip->new(); + $zip->addTree($src, $dest, $pred); + @memberNames = $zip->memberNames(); +} + +sub makeZipAndLookFor { + my ($src, $dest, $pred, $lookFor) = @_; + makeZip($src, $dest, $pred); + ok(@memberNames); + ok((grep { $_ eq $lookFor } @memberNames) == 1) + or print STDERR "Can't find $lookFor in (" + . join(",", @memberNames) . ")\n"; +} + +my ($testFileVolume, $testFileDirs, $testFileName) = File::Spec->splitpath($0); + +makeZipAndLookFor('.', '', sub { print "file $_\n"; -f && /\.t$/ }, + 't/02_main.t'); +makeZipAndLookFor('.', 'e/', sub { -f && /\.t$/ }, 'e/t/02_main.t'); +makeZipAndLookFor('./t', '', sub { -f && /\.t$/ }, '02_main.t'); |