changeset 13204:be7bfd59300a

Add tests for scripts/plot (plot/figure.m, plot/ishold.m, plot/ishold.m, plot/newplot.m): Add tests.
author Kai Habel <kai.habel@gmx.de>
date Fri, 23 Sep 2011 22:18:05 +0200
parents b6aba5b4edb1
children abf1e00111dd
files scripts/plot/figure.m scripts/plot/hold.m scripts/plot/ishold.m scripts/plot/newplot.m
diffstat 4 files changed, 71 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/figure.m	Fri Sep 23 15:03:29 2011 -0400
+++ b/scripts/plot/figure.m	Fri Sep 23 22:18:05 2011 +0200
@@ -80,3 +80,12 @@
   endif
 
 endfunction
+
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   assert (gcf, hf);
+%!   assert (isfigure (hf));
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
\ No newline at end of file
--- a/scripts/plot/hold.m	Fri Sep 23 15:03:29 2011 -0400
+++ b/scripts/plot/hold.m	Fri Sep 23 22:18:05 2011 +0200
@@ -139,3 +139,35 @@
 %! colorbar ("SouthOutside");
 %! title ("Test script for some plot functions");
 
+##hold on
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   p = plot ([0 1]);
+%!   assert (!ishold);
+%!   hold on;
+%!   assert (ishold);
+%!   p1 = fill ([0 1 1], [0 0 1],"black");
+%!   p2 = fill ([0 1 0], [0 1 1], "red");
+%!   assert (length (get (hf, "children")), 1);
+%!   assert (length (get (gca, "children")), 3);
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
+
+##hold off
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   p = plot ([0 1]);
+%!   assert (!ishold);
+%!   hold on;
+%!   assert (ishold);
+%!   p1 = fill ([0 1 1], [0 0 1],"black");
+%!   hold off
+%!   p2 = fill ([0 1 0], [0 1 1], "red");
+%!   assert (length (get (hf, "children")), 1);
+%!   assert (length (get (gca, "children")), 1);
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
--- a/scripts/plot/ishold.m	Fri Sep 23 15:03:29 2011 -0400
+++ b/scripts/plot/ishold.m	Fri Sep 23 22:18:05 2011 +0200
@@ -58,3 +58,23 @@
             && strcmpi (get (ax, "nextplot"), "add"));
 
 endfunction
+
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   l = plot ([0 1]);
+%!   assert (!ishold);
+%!   assert (!ishold (gca));
+%!   assert (get (gca, "NextPlot"), "replace");
+%!   assert (get (hf, "NextPlot"), "add");
+%!   hold;
+%!   assert (ishold);
+%!   assert (ishold (gca));
+%!   assert (get (gca, "NextPlot"), "add");
+%!   assert (get (hf, "NextPlot"), "add");
+%!   p = fill ([0 1 1], [0 0 1],"black");
+%!   assert (length (get (hf, "children")), 1);
+%!   assert (length (get (gca, "children")), 2);
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
--- a/scripts/plot/newplot.m	Fri Sep 23 15:03:29 2011 -0400
+++ b/scripts/plot/newplot.m	Fri Sep 23 22:18:05 2011 +0200
@@ -64,3 +64,13 @@
   endif
 
 endfunction
+
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   p = plot ([0, 1]);
+%!   newplot;
+%!   assert (isempty (get (gca, "children")));
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect