* changed t31tic_color.t to check against different images based on the presence...
[imager-graph.git] / t / t33_long_labels.t
CommitLineData
267997be 1use strict;
2
3use Imager::Graph::Line;
4use lib 't/lib';
5use Imager::Font::Test;
6use Test::More;
7
8-d 'testout'
9 or mkdir "testout", 0700
10 or die "Could not create output directory: $!";
11
12++$|;
13
14my @warned;
15local $SIG{__WARN__} =
16 sub {
17 print STDERR $_[0];
18 push @warned, $_[0]
19 };
20
21
22use Imager qw(:handy);
23
24plan tests => 2;
25
26
27my $font = Imager::Font::Test->new();
28
29my $graph = Imager::Graph::Line->new();
30$graph->set_image_width(900);
31$graph->set_image_height(600);
32$graph->set_font($font);
33
34$graph->add_data_series([1, 2]);
35$graph->set_labels(['AWWWWWWWWWWWWWWA', 'AWWWWWWWWWWWWWWWWWWWWWWWWWWWWWA']);
36
37my $img = $graph->draw() || warn $graph->error;
38
39$img->write(file=>'testout/t33_long_labels.ppm') or die "Can't save img1: ".$img->errstr."\n";
40cmpimg($img, 'testimg/t33_long_labels.ppm', 1);
41
42unless (is(@warned, 0, "should be no warnings")) {
43 diag($_) for @warned;
44}
45
46
47sub cmpimg {
48 my ($img, $file, $limit) = @_;
49
50 $limit ||= 10000;
51
52 my $cmpimg = Imager->new;
53 $cmpimg->read(file=>$file)
54 or return ok(0, "Cannot read $file: ".$cmpimg->errstr);
55 my $diff = Imager::i_img_diff($img->{IMG}, $cmpimg->{IMG});
56 cmp_ok($diff, '<', $limit, "Comparison to $file ($diff)");
57
58}
59