X-Git-Url: http://git.imager.perl.org/imager.git/blobdiff_plain/867acf5b8663b5b5944dbceacef4d346fe70eae1..5b9d88fd46727eb938bc1e87d5e783751b96021c:/t/t65crop.t diff --git a/t/t65crop.t b/t/t65crop.t index 3f2728d1..3adaa151 100644 --- a/t/t65crop.t +++ b/t/t65crop.t @@ -1,11 +1,13 @@ #!perl -w use strict; -use Test::More tests => 60; -require "t/testtools.pl"; +use Test::More tests => 64; use Imager; +use Imager::Test qw(test_image); #$Imager::DEBUG=1; +-d "testout" or mkdir "testout"; + Imager::init('log'=>'testout/t65crop.log'); my $img=Imager->new() || die "unable to create image object\n"; @@ -46,7 +48,7 @@ SKIP: # the left of the image, even if left/top are provided, despite the # sample in the docs # Let's make sure that things happen as documented - my $src = test_oo_img(); + my $src = test_image(); # make sure we get what we want is($src->getwidth, 150, "src width"); is($src->getheight, 150, "src height"); @@ -146,7 +148,7 @@ SKIP: { # https://rt.cpan.org/Ticket/Display.html?id=7581 # previously we didn't check that the result had some pixels # make sure we do - my $src = test_oo_img(); + my $src = test_image(); ok(!$src->crop(left=>50, right=>50), "nothing across"); cmp_ok($src->errstr, '=~', qr/resulting image would have no content/, "and message"); @@ -170,3 +172,13 @@ SKIP: cmp_ok($warning, '=~', 'void', "correct warning"); cmp_ok($warning, '=~', 't65crop\\.t', "correct file"); } + +{ + my $src = test_image(); + ok(!$src->crop( top=>1000, bottom=>1500, left=>0, right=>100 ), + "outside of image" ); + cmp_ok($src->errstr, '=~', qr/outside of the image/, "and message"); + ok(!$src->crop( top=>100, bottom=>1500, left=>1000, right=>1500 ), + "outside of image" ); + cmp_ok($src->errstr, '=~', qr/outside of the image/, "and message"); +}