diff scripts/sparse/etreeplot.m @ 28901:3c37ae43996a

maint: Code cleanup associated with varargin checking. * runtests.m, flipdim.m: Add newline before "endfunction" for looks. * check_default_input.m: Replace varargin in function prototype with explicit variables y0, yp0. Add input validation on nargin. * annotation.m: Use standard "mod (numel (), 2) != 0" test to check for even number of PROP/VAL pairs. * comet.m: Validate nargin does not exceed number of possible args. * cylinder.m: Move input validation for nargin to top of function. * ostreamtube.m, stream2.m, stream3.m, streamribbon.m, streamtube.m: Call print_usage() if number of input arguments is incorrect rather than homegrown error text. Make error() message for OPTIONS input more specific about what is wrong. Adjust input validation tests to pass again. * __plt__.m: Move input validation for number of inputs to top of function. * rectangle.m: Hyphenate "4-element vector" in error() message. * rose.m: Add input validation for maximum number of inputs. Add BIST test to check new code. * tetramesh.m: Use numel() in preference to length(). * pan.m, rotate3d.m, zoom.m: Switch from using varargin to explictly named input arguments. * etreeplot.m: Add check on maximum number of input arguments. Add BIST tests for input validation code. * strchr.m: Add check on maximum number of input arguments. Add BIST test for new input validation code.
author Rik <rik@octave.org>
date Tue, 13 Oct 2020 11:36:33 -0700
parents bd51beb6205e
children 7854d5752dd2
line wrap: on
line diff
--- a/scripts/sparse/etreeplot.m	Tue Oct 13 20:08:05 2020 +0200
+++ b/scripts/sparse/etreeplot.m	Tue Oct 13 11:36:33 2020 -0700
@@ -36,10 +36,15 @@
 
 function etreeplot (A, varargin)
 
-  if (nargin < 1)
+  if (nargin < 1 || nargin > 3)
     print_usage ();
   endif
 
   treeplot (etree (A+A'), varargin{:});
 
 endfunction
+
+
+## Test input validation
+%!error <Invalid call> etreeplot ()
+%!error <Invalid call> etreeplot (1,2,3,4)