Mercurial > hg > octave-nkf
changeset 19371:751d4a76c221
parseparams.m: Add BIST tests to function.
* parseparams.m: Add seealso link to inputParser function.
Add BIST tests to function.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 27 Sep 2014 22:39:24 -0700 |
parents | e360368bd49c |
children | ac8a49be686f |
files | scripts/miscellaneous/parseparams.m |
diffstat | 1 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/parseparams.m +++ b/scripts/miscellaneous/parseparams.m @@ -52,7 +52,7 @@ ## name of the caller function. ## The matching of options is case-insensitive. ## -## @seealso{varargin} +## @seealso{varargin, inputParser} ## @end deftypefn ## Author: Alexander Barth <abarth93@users.sourceforge.net> @@ -105,3 +105,25 @@ error ([fname, ": ", msg], varargin{:}); endfunction + +%!test +%! [reg, prop] = parseparams ({1, 2, "linewidth", 10}); +%! assert (reg, {[1], [2]}); +%! assert (prop, {"linewidth", 10}); +%!test +%! [reg, prop] = parseparams ({1, 2, 3}); +%! assert (reg, {[1], [2], [3]}); +%! assert (isempty (prop)); +%!test +%! [reg, prop] = parseparams ({"prop1", "val1"}); +%! assert (isempty (reg)); +%! assert (prop, {"prop1", "val1"}); +%!test +%! [reg, prop1] = parseparams ({"linewidth", 5}, "linewidth", 10); +%! assert (isempty (reg)); +%! assert (prop1, 5); + +%!error <needs odd number of arguments> parseparams ({1}, "linewidth") +%!error <must be given as name-value pairs> parseparams ({1, "color"}, "linewidth", 5) +%!error <unrecognized option: color> parseparams ({1, "color", 5}, "linewidth", 5) +