]> git.imager.perl.org - imager.git/blobdiff - t/t65crop.t
Merge branch 'psamp'
[imager.git] / t / t65crop.t
index 3f2728d1fa2b29fd600ef5d8f70a57ed21d90b34..3adaa1516fe638f4c5f2c634c31d4a4a327e4ca8 100644 (file)
@@ -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");
+}