ICO/t/t30cursor.t

filter: Statementstmt 100% 57 / 57 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 91.8% 68 / 74 CC 1 SCAR 0.0
CC
1
Cov
91%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« compose.im ↑ Summary combine.im »
1 #!perl -w
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Test::More tests => 25;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶BEGIN { use_ok('Imager::File::CUR'); }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶-d 'testout' or mkdir 'testout', 0777;
Branch: 1 branch
BranchTrueFalseTotal
-d "testout" or mkdir "testout", 511 1 0 1
8  
9 1 my $im = Imager->new;
10  
11 1 ok($im->read(file => 'testimg/pal43232.cur', type=>'cur'),
12 "read 4 bit");
13 1 is($im->getwidth, 32, "check width");
14 1 is($im->getheight, 32, "check width");
15 1 is($im->type, 'paletted', "check type");
16 1 is($im->tags(name => 'cur_bits'), 4, "check cur_bits tag");
17 1 is($im->tags(name => 'i_format'), 'cur', "check i_format tag");
18 1 is($im->tags(name => 'cur_hotspotx'), 1, "check cur_hotspotx tag");
19 1 is($im->tags(name => 'cur_hotspoty'), 18, "check cur_hotspoty tag");
20 1 my $mask = ".*" . ("\n" . "." x 32) x 32;
21 1 is($im->tags(name => 'cur_mask'), $mask, "check cur_mask tag");
22  
23 # these should get pushed back into range on saving
24 1 $im->settag(name => 'cur_hotspotx', value => 32);
25 1 $im->settag(name => 'cur_hotspoty', value => -1);
26 1 ▶ok($im->write(file=>'testout/hotspot.cur', type=>'cur'),
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $im->write("file", "testout/hotspot.cur", "type", "cur"), "save with oor hotspot") or print "# ", $im->errstr, "\n" 1 0 1
27 "save with oor hotspot")
28 or print "# ",$im->errstr, "\n";
29 {
30 1 my $im2 = Imager->new;
31 1 ▶ ok($im2->read(file=>'testout/hotspot.cur', type=>'cur'),
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $im2->read("file", "testout/hotspot.cur", "type", "cur"), "re-read the hotspot set cursor") or print "# ", $im->errstr, "\n" 1 0 1
32 "re-read the hotspot set cursor")
33 or print "# ", $im->errstr, "\n";
34 1 is($im2->tags(name => 'cur_hotspotx'), 31, "check cur_hotspotx tag");
35 1 is($im2->tags(name => 'cur_hotspoty'), 0, "check cur_hotspoty tag");
36 }
37  
38 1 $im->settag(name => 'cur_hotspotx', value => -1);
39 1 $im->settag(name => 'cur_hotspoty', value => 32);
40 1 ▶ok($im->write(file=>'testout/hotspot2.cur', type=>'cur'),
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $im->write("file", "testout/hotspot2.cur", "type", "cur"), "save with oor hotspot") or print "# ", $im->errstr, "\n" 1 0 1
41 "save with oor hotspot")
42 or print "# ",$im->errstr, "\n";
43  
44 {
45 1 my $im2 = Imager->new;
46 1 ▶ ok($im2->read(file=>'testout/hotspot2.cur', type=>'cur'),
Branch: 1 branch
BranchTrueFalseTotal
&ok(scalar $im2->read("file", "testout/hotspot2.cur", "type", "cur"), "re-read the hotspot set cursor") or print "# ", $im->errstr, "\n" 1 0 1
47 "re-read the hotspot set cursor")
48 or print "# ", $im->errstr, "\n";
49 1 is($im2->tags(name => 'cur_hotspotx'), 0, "check cur_hotspotx tag");
50 1 is($im2->tags(name => 'cur_hotspoty'), 31, "check cur_hotspoty tag");
51 }
52  
53 {
54 1 my $data = '';
55 1 ok($im->write(data => \$data, type => 'cur'),
56 "write single to data");
57 1 print "# ", length $data, " bytes written\n";
58 1 my $im2 = Imager->new;
59 1 ok($im2->read(data => $data), "read back in");
60 1 is(Imager::i_img_diff($im->{IMG}, $im2->{IMG}), 0, "check image");
61 }
62  
63 {
64 1 my $data = '';
65 1 ok(Imager->write_multi({ type => 'cur', data => \$data }, $im, $im),
66 "write multiple images");
67 1 print "# ", length $data, " bytes written\n";
68 1 ▶ my @im = Imager->read_multi(type => 'cur', data => $data)
Branch: 1 branch
BranchTrueFalseTotal
my(@im) = "Imager"->read_multi("type", "cur", "data", $data) or print "# ", "Imager"->errstr, "\n" 1 0 1
69 or print "# ", Imager->errstr, "\n";
70 1 is(@im, 2, "read them back in");
71 1 is(Imager::i_img_diff($im->{IMG}, $im[0]{IMG}), 0, "check first image");
72 1 is(Imager::i_img_diff($im->{IMG}, $im[1]{IMG}), 0, "check second image");
73 }
« compose.im ↑ Summary combine.im »