Mercurial > hg > octave-thorsten
changeset 13115:cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
plot/line.m: Style fixes and test added.
plot/patch.m: Tests added.
plot/surface.m: Allow surface to be called w/o arguments. Tests added.
plot/private/__patch__.m: Allow patch to be called w/o arguments.
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Thu, 08 Sep 2011 15:43:40 +0200 |
parents | 7600200a54c8 |
children | 9fc95b9f8001 |
files | scripts/plot/line.m scripts/plot/patch.m scripts/plot/private/__patch__.m scripts/plot/surface.m |
diffstat | 4 files changed, 50 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/line.m +++ b/scripts/plot/line.m @@ -47,12 +47,13 @@ %! hf = figure (1232, "visible", "off"); %! unwind_protect %! h = line; +%! assert (findobj (hf, "type", "line"), h); %! assert (get (h, "xdata"), [0 1], eps); %! assert (get (h, "ydata"), [0 1], eps); %! assert (get (h, "type"), "line"); -%! assert (get (h, "color"), get(0,'defaultlinecolor')); -%! assert (get (h, "linestyle"), get(0,'defaultlinelinestyle')); -%! assert (get (h, "linewidth"), get(0,'defaultlinelinewidth'), eps); +%! assert (get (h, "color"), get (0, "defaultlinecolor")); +%! assert (get (h, "linestyle"), get (0, "defaultlinelinestyle")); +%! assert (get (h, "linewidth"), get (0, "defaultlinelinewidth"), eps); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect
--- a/scripts/plot/patch.m +++ b/scripts/plot/patch.m @@ -152,3 +152,23 @@ %! 'FaceVertexCData', jet(5), 'FaceColor', 'interp') %! view (-37.5, 30) +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! h = patch; +%! assert (findobj (hf, "type", "patch"), h); +%! assert (get (h, "xdata"), [0; 1; 1], eps); +%! assert (get (h, "ydata"), [0; 0; 1], eps); +%! assert (isempty(get (h, "zdata"))); +%! assert (isempty(get (h, "cdata"))); +%! assert (get (h, "faces"), [1, 2, 3], eps); +%! assert (get (h, "vertices"), [0 0; 1 0; 1 1], eps); +%! assert (get (h, "type"), "patch"); +%! assert (get (h, "facecolor"), [0 0 1]); +%! assert (get (h, "linestyle"), get (0, "defaultpatchlinestyle")); +%! assert (get (h, "linewidth"), get (0, "defaultpatchlinewidth"), eps); +%! assert (get (h, "marker"), get (0, "defaultpatchmarker")); +%! assert (get (h, "markersize"), get (0, "defaultpatchmarkersize")); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect
--- a/scripts/plot/private/__patch__.m +++ b/scripts/plot/private/__patch__.m @@ -31,7 +31,10 @@ failed = false; - if (isstruct (varargin{1})) + if (isempty (varargin)) + args = {"xdata", [0; 1; 1], "ydata", [0; 0; 1], "facecolor", "blue"}; + args = setvertexdata (args); + elseif (isstruct (varargin{1})) if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces")) args{1} = "faces"; args{2} = getfield(varargin{1}, "faces");
--- a/scripts/plot/surface.m +++ b/scripts/plot/surface.m @@ -136,6 +136,10 @@ else error ("surface: Z argument must be a matrix"); endif + elseif (firststring == 1) + x = 1:3; + y = (x).'; + c = z = eye(3); else bad_usage = true; endif @@ -158,4 +162,21 @@ ## Mark file as being tested. Tests for surface are in ## surf.m, surfc.m, surfl.m, and pcolor.m -%!assert(1) + +%!test +%! hf = figure (1232, "visible", "off"); +%! unwind_protect +%! h = surface; +%! assert (findobj (hf, "type", "surface"), h); +%! assert (get (h, "xdata"), 1:3, eps); +%! assert (get (h, "ydata"), (1:3)', eps); +%! assert (get (h, "zdata"), eye(3)); +%! assert (get (h, "cdata"), eye(3)); +%! assert (get (h, "type"), "surface"); +%! assert (get (h, "linestyle"), get (0, "defaultsurfacelinestyle")); +%! assert (get (h, "linewidth"), get (0, "defaultsurfacelinewidth"), eps); +%! assert (get (h, "marker"), get (0, "defaultsurfacemarker")); +%! assert (get (h, "markersize"), get (0, "defaultsurfacemarkersize")); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect