3 use Test::More tests => 7;
4 BEGIN { use_ok("Imager", ":all") }
6 -d "testout" or mkdir "testout";
8 init_log("testout/t05error.log", 1);
10 # try to read an invalid pnm file
11 open FH, "< testimg/junk.ppm"
12 or die "Cannot open testin/junk: $!";
14 my $IO = Imager::io_new_fd(fileno(FH));
15 my $im = i_readpnm_wiol($IO, -1);
17 ok(!$im, "read of junk.ppm should have failed")
18 or skip("read didn't fail!", 5);
20 my @errors = Imager::i_errors();
22 is(scalar @errors, 1, "got the errors")
23 or skip("no errors to check", 4);
27 my $error0 = $errors[0];
28 is(ref $error0, "ARRAY", "entry 0 is an array ref")
29 or skip("entry 0 not an array", 3);
31 is(scalar @$error0, 2, "entry 0 has 2 elements")
32 or skip("entry 0 doesn't have enough elements", 2);
34 is($error0->[0], "while skipping to height", "check message");
35 is($error0->[1], "0", "error code should be 0");