From 5cfde30f09a1f3de8bb7f24cb068ab08cfb7a860 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Wed, 25 Nov 2009 06:50:51 +0000 Subject: [PATCH] make sure flipping paletted images is covered --- lib/Imager/Test.pm | 13 ++++++++++++- t/t64copyflip.t | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/Imager/Test.pm b/lib/Imager/Test.pm index 6e11b51a..8d66ecb2 100644 --- a/lib/Imager/Test.pm +++ b/lib/Imager/Test.pm @@ -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; diff --git a/t/t64copyflip.t b/t/t64copyflip.t index 87149842..e8229335 100644 --- a/t/t64copyflip.t +++ b/t/t64copyflip.t @@ -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); -- 2.39.5