3 use Test::More tests => 8;
5 -d "testout" or mkdir "testout";
7 Imager::init("log"=>'testout/t68map.log');
9 use Imager qw(:all :handy);
11 my $imbase = Imager::ImgRaw::new(200,300,3);
14 my @map1 = map { int($_/2) } 0..255;
15 my @map2 = map { 255-int($_/2) } 0..255;
22 ok(i_map($imbase, [ [], [], \@map1 ]), "map1 in ch 3");
23 ok(i_map($imbase, [ \@map1, \@map1, \@map1 ]), "map1 in ch1-3");
25 ok(i_map($imbase, [ \@map1, \@map2, \@map3 ]), "map1-3 in ch 1-3");
27 ok(i_map($imbase, [ \@maps, \@mapl, \@map3 ]), "incomplete maps");
29 # test the highlevel interface
30 # currently this requires visual inspection of the output files
34 $im->read(file=>'testimg/scale.ppm')
35 or skip "Cannot load test image testimg/scale.ppm", 2;
37 ok( $im->map(red=>\@map1, green=>\@map2, blue=>\@map3),
38 "test OO interface (maps by color)");
39 ok( $im->map(maps=>[\@map1, [], \@map2]),
40 "test OO interface (maps by maps)");
44 my $empty = Imager->new;
45 ok(!$empty->map(maps => [ \@map1, \@map2, \@map3 ]),
46 "can't map an empty image");
47 is($empty->errstr, "map: empty input image", "check error message");