make sure flipping paletted images is covered
authorTony Cook <tony@develop=help.com>
Wed, 25 Nov 2009 06:50:51 +0000 (06:50 +0000)
committerTony Cook <tony@develop=help.com>
Wed, 25 Nov 2009 06:50:51 +0000 (06:50 +0000)
lib/Imager/Test.pm
t/t64copyflip.t

index 6e11b51a3260311d19692a2cb6d2b30d33508d49..8d66ecb26b532fb2f21ff6c713df27f16911f22c 100644 (file)
@@ -19,7 +19,8 @@ use vars qw(@ISA @EXPORT_OK);
      color_cmp
      is_image
      is_imaged
-     is_image_similar 
+     is_image_similar
+     isnt_image
      image_bounds_checks
      mask_tests
      test_colorf_gpix
@@ -391,6 +392,16 @@ sub is_imaged($$$) {
   return $builder->ok(1, $comment);
 }
 
+sub isnt_image {
+  my ($left, $right, $comment) = @_;
+
+  my $builder = Test::Builder->new;
+
+  my $diff = Imager::i_img_diff($left->{IMG}, $right->{IMG});
+
+  return $builder->ok($diff, "$comment");
+}
+
 sub image_bounds_checks {
   my $im = shift;
 
index 87149842f7bff91fb946dec2b05406ed16a64d10..e8229335ba4219e296868ca6a72c6673e716dbe1 100644 (file)
@@ -1,8 +1,8 @@
 #!perl -w
 use strict;
-use Test::More tests => 69;
+use Test::More tests => 77;
 use Imager;
-use Imager::Test qw(is_color3 is_image is_imaged test_image_double);
+use Imager::Test qw(is_color3 is_image is_imaged test_image_double test_image isnt_image);
 
 #$Imager::DEBUG=1;
 
@@ -44,6 +44,19 @@ is_image($img, $nimg, "check flip with hv matches flip v then flip h");
   is_imaged($imsrc, $imcp, "flip h,v,hv twice");
 }
 
+{
+  my $impal = test_image()->to_paletted;
+  my $imcp = $impal->copy;
+  is($impal->type, "paletted", "check paletted test image is");
+  is($imcp->type, "paletted", "check copy test image is paletted");
+  ok($impal->flip(dir => "h"), "flip paletted h");
+  isnt_image($impal, $imcp, "check it changed");
+  ok($impal->flip(dir => "v"), "flip paletted v");
+  ok($impal->flip(dir => "hv"), "flip paletted hv");
+  is_image($impal, $imcp, "should be back to original image");
+  is($impal->type, "paletted", "and still paletted");
+}
+
 rot_test($img, 90, 4);
 rot_test($img, 180, 2);
 rot_test($img, 270, 4);