]> git.imager.perl.org - imager.git/blob - t/t68map.t
prefer static first
[imager.git] / t / t68map.t
1 #!perl -w
2 use strict;
3 use Test::More tests => 8;
4
5 -d "testout" or mkdir "testout";
6
7 Imager::init("log"=>'testout/t68map.log');
8
9 use Imager qw(:all :handy);
10
11 my $imbase = Imager::ImgRaw::new(200,300,3);
12
13
14 my @map1 = map { int($_/2) } 0..255;
15 my @map2 = map { 255-int($_/2) } 0..255;
16 my @map3 = 0..255;
17 my @maps = 0..24;
18 my @mapl = 0..400;
19
20 my $tst = 1;
21
22 ok(i_map($imbase, [ [],     [],     \@map1 ]), "map1 in ch 3");
23 ok(i_map($imbase, [ \@map1, \@map1, \@map1 ]), "map1 in ch1-3");
24
25 ok(i_map($imbase, [ \@map1, \@map2, \@map3 ]), "map1-3 in ch 1-3");
26
27 ok(i_map($imbase, [ \@maps, \@mapl, \@map3 ]), "incomplete maps");
28
29 # test the highlevel interface
30 # currently this requires visual inspection of the output files
31
32 SKIP: {
33   my $im = Imager->new;
34   $im->read(file=>'testimg/scale.ppm')
35     or skip "Cannot load test image testimg/scale.ppm", 2;
36
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)");
41 }
42
43 {
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");
48 }