Sony.t 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Before "make install", this script should be runnable with "make test".
  2. # After "make install" it should work as "perl t/Sony.t".
  3. BEGIN { $| = 1; print "1..5\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::Sony;
  8. $loaded = 1;
  9. print "ok 1\n";
  10. use t::TestLib;
  11. my $testname = 'Sony';
  12. my $testnum = 1;
  13. # test 2: Extract information from Sony.jpg
  14. {
  15. ++$testnum;
  16. my $exifTool = new Image::ExifTool;
  17. my $info = $exifTool->ImageInfo('t/images/Sony.jpg',{Unknown=>1});
  18. print 'not ' unless check($exifTool, $info, $testname, $testnum);
  19. print "ok $testnum\n";
  20. }
  21. # test 3: Write some new information
  22. {
  23. ++$testnum;
  24. my @writeInfo = (
  25. [FlashFired => 'true'],
  26. [ISO => undef],
  27. );
  28. print 'not ' unless writeCheck(\@writeInfo, $testname, $testnum);
  29. print "ok $testnum\n";
  30. }
  31. # test 4: Test Sony decryption
  32. {
  33. ++$testnum;
  34. my $data = pack('N', 0x34a290d3);
  35. Image::ExifTool::Sony::Decrypt(\$data, 0, 4, 0x12345678);
  36. my $expected = 0x20677968;
  37. my $got = unpack('N', $data);
  38. unless ($got == $expected) {
  39. warn "\n Test $testnum (decryption) returned wrong value:\n";
  40. warn sprintf(" Expected 0x%x but got 0x%x\n", $expected, $got);
  41. print 'not ';
  42. }
  43. print "ok $testnum\n";
  44. }
  45. # test 5: Extract information from a PMP image
  46. {
  47. ++$testnum;
  48. my $exifTool = new Image::ExifTool;
  49. my $info = $exifTool->ImageInfo('t/images/Sony.pmp');
  50. print 'not ' unless check($exifTool, $info, $testname, $testnum);
  51. print "ok $testnum\n";
  52. }
  53. # end