ZIP.t 1.9 KB

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