1# Before "make install", this script should be runnable with "make test".
2# After "make install" it should work as "perl t/ZIP.t".
3
4BEGIN {
5    $| = 1; print "1..7\n"; $Image::ExifTool::configFile = '';
6    require './t/TestLib.pm'; t::TestLib->import();
7}
8END {print "not ok 1\n" unless $loaded;}
9
10# test 1: Load the module(s)
11use Image::ExifTool 'ImageInfo';
12use Image::ExifTool::ZIP;
13$loaded = 1;
14print "ok 1\n";
15
16my $testname = 'ZIP';
17my $testnum = 1;
18my $failed;
19
20# tests 2-3: Extract information from test ZIP and GZIP files
21{
22    my $exifTool = new Image::ExifTool;
23    my $type;
24    foreach $type (qw(zip gz)) {
25        ++$testnum;
26        my $info = $exifTool->ImageInfo("t/images/ZIP.$type");
27        print 'not ' and $failed = 1 unless check($exifTool, $info, $testname, $testnum);
28        print "ok $testnum\n";
29    }
30}
31
32# tests 4-7: Extract information from other ZIP-based files (requires Archive::Zip)
33{
34    my $exifTool = new Image::ExifTool;
35    my $file;
36    foreach $file ('OOXML.docx', 'CaptureOne.eip', 'iWork.numbers', 'OpenDoc.ods') {
37        ++$testnum;
38        my $skip = '';
39        if (eval 'require Archive::Zip') {
40            my $info = $exifTool->ImageInfo("t/images/$file");
41            print 'not ' and $failed = 1 unless check($exifTool, $info, $testname, $testnum);
42        } else {
43            $skip = ' # skip Requires Archive::Zip';
44        }
45        print "ok $testnum$skip\n";
46    }
47}
48
49# pass on any Archive::Zip warning
50if ($Image::ExifTool::ZIP::warnString) {
51    warn $Image::ExifTool::ZIP::warnString;
52}
53
54# print module versions if anything failed
55if ($failed) {
56    my $mod;
57    warn "\n";
58    foreach $mod ('Archive::Zip', 'Compress::Raw::Zlib', 'IO::String') {
59        my $v;
60        if (eval "require $mod") {
61            my $var = $mod . '::VERSION';
62            no strict 'refs';
63            $v = $$var;
64        }
65        my $w = $v ? "version is $v" : 'is not installed';
66        warn "    ($mod $w)\n";
67    }
68}
69
70# end
71