File: t40limit.t

package info (click to toggle)
libimager-perl 1.005%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,308 kB
  • ctags: 4,067
  • sloc: perl: 30,915; ansic: 27,680; makefile: 55; cpp: 4
file content (88 lines) | stat: -rw-r--r-- 2,928 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!perl -w
use Imager;
use Test::More tests => 22;
use Imager::Test qw(is_image);

{
  # GIF files are limited to 0xFFFF x 0xFFFF pixels
  {
    my $im = Imager->new(xsize => 0x10000, ysize => 1);
    my $data = '';
    ok(!$im->write(data => \$data, type => "gif"),
       "fail to write too wide an image");
    is($im->errstr, "image too large for GIF",
       "check error message");
  }
 SKIP:
  {
    my $im = Imager->new(xsize => 0xFFFF, ysize => 1);
    $im->box(fill => { hatch => "check4x4" });
    my $data = '';
    ok($im->write(data => \$data, type => "gif"),
       "write image at width limit");
    my $im2 = Imager->new(data => $data, ftype => "gif");
    ok($im2, "read it ok")
      or skip("cannot load the wide image", 1);
    is_image($im, $im2, "check we read what we wrote");
    is($im->getwidth, 0xffff, "check width");
    is($im->getheight, 1, "check height");
  }
  {
    my $im = Imager->new(xsize => 1, ysize => 0x10000);
    my $data = '';
    ok(!$im->write(data => \$data, type => "gif"),
       "fail to write too tall an image");
    is($im->errstr, "image too large for GIF",
       "check error message");
  }
 SKIP:
  {
    my $im = Imager->new(xsize => 1, ysize => 0xFFFF);
    $im->box(fill => { hatch => "check2x2" });
    my $data = '';
    ok($im->write(data => \$data, type => "gif"),
       "write image at width limit");
    my $im2 = Imager->new(data => $data, ftype => "gif");
    ok($im2, "read it ok")
      or skip("cannot load the wide image", 1);
    is_image($im, $im2, "check we read what we wrote");
    is($im->getwidth, 1, "check width");
    is($im->getheight, 0xffff, "check height");
  }
}
{
  my $im = Imager->new(xsize => 1, ysize => 1);
  $im->settag(name => "gif_screen_width", value => 65536);
  my $data = '';
  ok(!$im->write(data => \$data, type => "gif"),
     "save a with a large explicit screen width should fail");
  is($im->errstr, "screen size too large for GIF",
     "check error message");
}
{
  my $im = Imager->new(xsize => 0x8000, ysize => 1);
  $im->settag(name => "gif_left", value => 32768);
  my $data = '';
  ok(!$im->write(data => \$data, type => "gif"),
     "save a with a large implicit screen width should fail");
  is($im->errstr, "screen size too large for GIF",
     "check error message");
}
{
  my $im = Imager->new(xsize => 1, ysize => 1);
  $im->settag(name => "gif_screen_height", value => 65536);
  my $data = '';
  ok(!$im->write(data => \$data, type => "gif"),
     "save a with a large explicit screen height should fail");
  is($im->errstr, "screen size too large for GIF",
     "check error message");
}
{
  my $im = Imager->new(xsize => 1, ysize => 0x8000);
  $im->settag(name => "gif_top", value => 32768);
  my $data = '';
  ok(!$im->write(data => \$data, type => "gif"),
     "save a with a large implicit screen height should fail");
  is($im->errstr, "screen size too large for GIF",
     "check error message");
}