convert t68map.t to Test::More
authorTony Cook <tony@develop-help.com>
Fri, 9 Nov 2012 10:57:45 +0000 (21:57 +1100)
committerTony Cook <tony@develop-help.com>
Fri, 14 Dec 2012 09:27:39 +0000 (20:27 +1100)
t/t68map.t

index 600887ded279d58b628812ac041f54504e1cca14..b453994011ca6fca3fa5a74de1103875df9524bc 100644 (file)
@@ -1,41 +1,41 @@
+#!perl -w
+use strict;
+use Test::More tests => 6;
+
 -d "testout" or mkdir "testout";
 
 Imager::init("log"=>'testout/t68map.log');
 
 use Imager qw(:all :handy);
 
-print "1..5\n";
-
 my $imbase = Imager::ImgRaw::new(200,300,3);
 
 
-@map1 = map { int($_/2) } 0..255;
-@map2 = map { 255-int($_/2) } 0..255;
-@map3 = 0..255;
-@maps = 0..24;
-@mapl = 0..400;
+my @map1 = map { int($_/2) } 0..255;
+my @map2 = map { 255-int($_/2) } 0..255;
+my @map3 = 0..255;
+my @maps = 0..24;
+my @mapl = 0..400;
 
-$tst = 1;
+my $tst = 1;
 
-i_map($imbase, [ [],     [],     \@map1 ]);
-print "ok ".$tst++."\n";
-i_map($imbase, [ \@map1, \@map1, \@map1 ]);
+ok(i_map($imbase, [ [],     [],     \@map1 ]), "map1 in ch 3");
+ok(i_map($imbase, [ \@map1, \@map1, \@map1 ]), "map1 in ch1-3");
 
-print "ok ".$tst++."\n";
-i_map($imbase, [ \@map1, \@map2, \@map3 ]);
+ok(i_map($imbase, [ \@map1, \@map2, \@map3 ]), "map1-3 in ch 1-3");
 
-print "ok ".$tst++."\n";
-i_map($imbase, [ \@maps, \@mapl, \@map3 ]);
+ok(i_map($imbase, [ \@maps, \@mapl, \@map3 ]), "incomplete maps");
 
 # test the highlevel interface
 # currently this requires visual inspection of the output files
 
+SKIP: {
+  my $im = Imager->new;
+  $im->read(file=>'testimg/scale.ppm')
+    or skip "Cannot load test image testimg/scale.ppm", 2;
 
-my $im = Imager->new;
-if ($im->read(file=>'testimg/scale.ppm')) {
-  print( ( $im->map(red=>\@map1, green=>\@map2, blue=>\@map3) ? "ok " : "not ok ").$tst++."\n" );
-  print( ( $im->map(maps=>[\@map1, [], \@map2]) ? "ok " : "not ok "). $tst++."\n");
-}
-else {
-  die "could not load testout/scale.ppm\n";
+  ok( $im->map(red=>\@map1, green=>\@map2, blue=>\@map3),
+      "test OO interface (maps by color)");
+  ok( $im->map(maps=>[\@map1, [], \@map2]),
+      "test OO interface (maps by maps)");
 }