Mercurial > hg > octave-nkf
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 +++ b/scripts/plot/figure.m @@ -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 +++ b/scripts/plot/hold.m @@ -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 +++ b/scripts/plot/ishold.m @@ -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 +++ b/scripts/plot/newplot.m @@ -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