From: Tony Cook Date: Fri, 23 Jul 2010 14:28:02 +0000 (+0000) Subject: slightly improve test coverage of methods X-Git-Tag: v0.08~8 X-Git-Url: http://git.imager.perl.org/imager-graph.git/commitdiff_plain/c8a3feda7edf5344c84f618095eaa4cab20aad9f slightly improve test coverage of methods --- diff --git a/t/t10pie.t b/t/t10pie.t index f57732b..d5a99cb 100644 --- a/t/t10pie.t +++ b/t/t10pie.t @@ -21,7 +21,7 @@ my $font = Imager::Font::Test->new(); my @data = ( 100, 180, 80, 20, 2, 1, 0.5 ); my @labels = qw(alpha beta gamma delta epsilon phi gi); -plan tests => 35; +plan tests => 41; my $pie = Imager::Graph::Pie->new; ok($pie, "creating pie chart object"); @@ -228,6 +228,48 @@ cmpimg($img6, "testimg/t10_hlegend.png", 550_000); is($pie->error, "Sum of all data values is zero", "check message"); } +{ + # test methods used to set features + # adds test coverage for otherwise uncovered methods + my $pie = Imager::Graph::Pie->new; + $pie->add_data_series(\@data); + $pie->set_labels(\@labels); + $pie->set_font($font); + $pie->set_style("mono"); + $pie->show_callouts_onAll_segments(); + $pie->show_label_percentages(); + $pie->set_legend_horizontal_align("right"); + $pie->set_legend_vertical_align("bottom"); + my $im = $pie->draw(); + + ok($im, "made mono test using methods"); + cmpimg($im, "testimg/t10_mono.png", 550_00); +} + +{ + # more method coverage + my $pie = Imager::Graph::Pie->new; + $pie->add_data_series(\@data); + $pie->set_labels(\@labels); + $pie->set_font($font); + $pie->set_style("fount_lin"); + $pie->show_legend(); + $pie->show_only_label_percentages(); + $pie->set_legend_vertical_align("center"); + my $im = $pie->draw(); + + ok($im, "made lin_found test using methods"); + cmpimg($im, "testimg/t10_lin_fount.png", 180_00); +} + +{ + my $pie = Imager::Graph::Pie->new; + my $im = $pie->draw(width => -1, data => \@data); + ok(!$im, "shouldn't be able to create neg width image"); + print "# ", $pie->error, "\n"; + cmp_ok($pie->error, '=~', qr/^Error creating image/, "check error message"); +} + sub cmpimg { my ($img, $file, $limit) = @_;