Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libarchive-zip-perl / libarchive-zip-perl-1.18 / t / 05_tree.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
5 use FileHandle;
6 use File::Spec;
7
8 use Test::More tests =>6;
9 BEGIN {
10     unshift @INC, "t/"; 
11     require( File::Spec->catfile('t', 'common.pl') )
12                 or die "Can't load t/common.pl";
13 }
14
15 use constant FILENAME => File::Spec->catfile(TESTDIR, 'testing.txt');
16
17 my $zip;
18 my @memberNames;
19
20 sub makeZip
21 {
22         my ($src, $dest, $pred) = @_;
23         $zip = Archive::Zip->new();
24         $zip->addTree($src, $dest, $pred);
25         @memberNames = $zip->memberNames();
26 }
27
28 sub makeZipAndLookFor
29 {
30         my ($src, $dest, $pred, $lookFor) = @_;
31         makeZip($src, $dest, $pred);
32         ok( @memberNames );
33         ok( (grep { $_ eq $lookFor } @memberNames) == 1 )
34                 or print STDERR "Can't find $lookFor in (" . join(",", @memberNames) . ")\n";
35 }
36
37 my ($testFileVolume, $testFileDirs, $testFileName) = File::Spec->splitpath($0);
38
39 makeZipAndLookFor('.', '', sub { print "file $_\n"; -f && /\.t$/ }, 't/02_main.t' );
40 makeZipAndLookFor('.', 'e/', sub { -f && /\.t$/ }, 'e/t/02_main.t');
41 makeZipAndLookFor('./t', '', sub { -f && /\.t$/ }, '02_main.t' );