slightly improve test coverage of methods
authorTony Cook <tony@develop-help.com>
Fri, 23 Jul 2010 14:28:02 +0000 (14:28 +0000)
committerTony Cook <tony@develop-help.com>
Fri, 23 Jul 2010 14:28:02 +0000 (14:28 +0000)
t/t10pie.t

index f57732b9c56c49b98ebccdf78b98adf55dc3851d..d5a99cbe8a39e7f5d7ebe8ad60f0cc0076989776 100644 (file)
@@ -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) = @_;