]> git.imager.perl.org - imager.git/blob - SGI/t/30limit.t
prefer static first
[imager.git] / SGI / t / 30limit.t
1 #!perl -w
2 use Imager;
3 use Test::More tests => 14;
4 use Imager::Test qw(is_image);
5
6 {
7   # SGI files are limited to 0xFFFF x 0xFFFF pixels
8   {
9     my $im = Imager->new(xsize => 0x10000, ysize => 1);
10     my $data = '';
11     ok(!$im->write(data => \$data, type => "sgi"),
12        "fail to write too wide an image");
13     is($im->errstr, "image too large for SGI",
14        "check error message");
15   }
16  SKIP:
17   {
18     my $im = Imager->new(xsize => 0xFFFF, ysize => 1);
19     $im->box(fill => { hatch => "check4x4" });
20     my $data = '';
21     ok($im->write(data => \$data, type => "sgi"),
22        "write image at width limit");
23     my $im2 = Imager->new(data => $data, ftype => "sgi");
24     ok($im2, "read it ok")
25       or skip("cannot load the wide image", 1);
26     is_image($im, $im2, "check we read what we wrote");
27     is($im->getwidth, 0xffff, "check width");
28     is($im->getheight, 1, "check height");
29   }
30   {
31     my $im = Imager->new(xsize => 1, ysize => 0x10000);
32     my $data = '';
33     ok(!$im->write(data => \$data, type => "sgi"),
34        "fail to write too tall an image");
35     is($im->errstr, "image too large for SGI",
36        "check error message");
37   }
38  SKIP:
39   {
40     my $im = Imager->new(xsize => 1, ysize => 0xFFFF);
41     $im->box(fill => { hatch => "check2x2" });
42     my $data = '';
43     ok($im->write(data => \$data, type => "sgi"),
44        "write image at width limit");
45     my $im2 = Imager->new(data => $data, ftype => "sgi");
46     ok($im2, "read it ok")
47       or skip("cannot load the wide image", 1);
48     is_image($im, $im2, "check we read what we wrote");
49     is($im->getwidth, 1, "check width");
50     is($im->getheight, 0xffff, "check height");
51   }
52 }