Mercurial > hg > octave-terminal
changeset 13096:5553412c6614
Tests for scripts/plot
* (allchild.m, ancestor.m, clf.m, findall.m, findobj.m, gcf.m,
line.m, view.m, whitebg.m, xlim.m, ylim.m, zlim.m): Add tests
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Sun, 04 Sep 2011 21:58:42 +0200 |
parents | 32fdd834c09a |
children | 52e4aa30d5b2 |
files | scripts/plot/allchild.m scripts/plot/ancestor.m scripts/plot/clf.m scripts/plot/findall.m scripts/plot/findobj.m scripts/plot/gcf.m scripts/plot/line.m scripts/plot/view.m scripts/plot/whitebg.m scripts/plot/xlim.m scripts/plot/ylim.m scripts/plot/zlim.m |
diffstat | 12 files changed, 191 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/allchild.m +++ b/scripts/plot/allchild.m @@ -48,3 +48,12 @@ end_unwind_protect endfunction + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! l = line; +%! assert(get(allchild(hf),'type'),{'axes'; 'uimenu'; 'uimenu'; 'uimenu'}) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/ancestor.m +++ b/scripts/plot/ancestor.m @@ -74,3 +74,13 @@ endif endfunction + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! l = line; +%! assert (ancestor (l, "axes"), gca); +%! assert (ancestor (l, "figure"), hf); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/clf.m +++ b/scripts/plot/clf.m @@ -75,3 +75,14 @@ delete (hc); endfunction + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! l = line; +%! assert (!isempty (get (gcf, "children"))); +%! clf; +%! assert (isempty (get (gcf, "children"))); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/findall.m +++ b/scripts/plot/findall.m @@ -42,3 +42,13 @@ end_unwind_protect endfunction + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! h = findall; +%! all_handles = {"uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "uimenu"; "root"; "figure"}; +%! assert (get (h, 'type'), all_handles) +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/findobj.m +++ b/scripts/plot/findobj.m @@ -242,3 +242,18 @@ h = h (keepers != 0); h = reshape (h, [numel(h), 1]); endfunction + +%!test +%! fign = 1232; +%! hf = figure (fign, "visible", "off"); +%! unwind_protect +%! l = line; +%! obj = findobj ("type", "line"); +%! assert (l, obj); +%! assert (gca, findobj ("type", "axes")); +%! assert (fign, findobj ("type", "figure")); +%! assert (0, findobj ("type", "root")); +%! assert (isempty (findobj ("type", "xyzxyz"))); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/gcf.m +++ b/scripts/plot/gcf.m @@ -53,3 +53,13 @@ endif endfunction + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! line; +%! clf; +%! assert (isempty (get (gcf, "children"))); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/line.m +++ b/scripts/plot/line.m @@ -42,3 +42,17 @@ endif endfunction + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! h = line; +%! assert (get (h, "xdata"), [0 1], eps); +%! assert (get (h, "ydata"), [0 1], eps); +%! assert (get (h, "type"), "line"); +%! assert (get (h, "color"), [0 0 0]); +%! assert (get (h, "linestyle"), "-"); +%! assert (get (h, "linewidth"), 0.5, eps); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/view.m +++ b/scripts/plot/view.m @@ -93,3 +93,34 @@ endif endfunction + +%!test +%! fign = 1232; +%! hf = figure (fign, "visible", "off"); +%! unwind_protect +%! plot3 ([0,1], [0,1], [0,1]); +%! [az, el] = view; +%! assert ([az, el], [-37.5, 30], eps); +%! view (2); +%! [az, el] = view; +%! assert ([az, el], [0, 90], eps); +%! view ([1 1 0]); +%! [az, el] = view; +%! assert ([az, el], [135, 0], eps); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! fign = 1232; +%! hf = figure (fign, "visible", "off"); +%! unwind_protect +%! line; +%! [az, el] = view; +%! assert ([az, el], [0, 90], eps); +%! view (3); +%! [az, el] = view; +%! assert ([az, el], [-37.5, 30], eps); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/whitebg.m +++ b/scripts/plot/whitebg.m @@ -143,3 +143,21 @@ endif endif endfunction + +%!test +%! set (0, "defaultaxescolor", [1 1 1]); +%! set (0, "defaultfigurecolor", [1 1 1]); +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! l = line; +%! assert (get (hf, "color"), [1 1 1]); +%! assert (get (gca, "color"), [1 1 1]); +%! whitebg; +%! assert (get (hf, "color"), [0 0 0]); +%! assert (get (gca, "color"), [0 0 0]); +%! whitebg([0.2 0.2 0.2]) +%! assert (get (hf, "color"), [0 0 0]); +%! assert (get (gca, "color"), [0.2 0.2 0.2]); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/xlim.m +++ b/scripts/plot/xlim.m @@ -73,5 +73,24 @@ %! title ("xlim is auto"); %! assert (xlim ("mode"), "auto"); -## Remove from test statistics. No real tests possible. -%!assert (1) + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! plot3 ([0,1], [0,1], [0,1]); +%! xlim ([0, 1.1]); +%! assert (get (gca, "xlim"), [0, 1.1], eps); +%! assert (xlim ("mode"), "manual"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! h = plot3 ([0,1.1], [0,1], [0, 1]); +%! assert (get (gca, "xlim"), [0, 1.4], eps); +%! assert (xlim ("mode"), "auto"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/ylim.m +++ b/scripts/plot/ylim.m @@ -73,5 +73,24 @@ %! title ("ylim is auto"); %! assert (ylim ("mode"), "auto"); -## Remove from test statistics. No real tests possible. -%!assert (1) +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! limy = [0, 1.1]; +%! plot3 ([0,1], [0,1], [0,1]); +%! ylim (limy); +%! assert (get (gca, "ylim"), limy, eps); +%! assert (ylim ("mode"), "manual"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! plot3 ([0,1], [0,1.1], [0, 1]); +%! assert (get (gca, "ylim"), [0, 1.4], eps); +%! assert (ylim ("mode"), "auto"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/zlim.m +++ b/scripts/plot/zlim.m @@ -73,5 +73,24 @@ %! title ("zlim is auto"); %! assert (zlim ("mode"), "auto"); -## Remove from test statistics. No real tests possible. -%!assert (1) +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! limz = [0, 1.1]; +%! plot3 ([0,1], [0,1], [0,1]); +%! zlim (limz); +%! assert (get (gca, "zlim"), limz, eps); +%! assert (zlim ("mode"), "manual"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! plot3 ([0,1], [0,1], [0, 1.1]); +%! assert (get (gca, "zlim"), [0, 1.4], eps); +%! assert (zlim ("mode"), "auto"); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect