Mercurial > hg > octave-lyh
changeset 16217:1f1e248caeab
unique.m: Correctly check invalid options (bug #38460)
* unique.m: Use ismember instead of strmatch to scan varargin. Add tests.
author | Julien Bect <julien.bect@supelec.fr> |
---|---|
date | Sun, 03 Mar 2013 19:59:26 +0100 |
parents | 70c47da7e02b |
children | 2d415053514e |
files | scripts/set/unique.m |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/set/unique.m +++ b/scripts/set/unique.m @@ -52,9 +52,9 @@ ## parse options if (iscellstr (varargin)) varargin = unique (varargin); - optfirst = strmatch ("first", varargin, "exact") > 0; - optlast = strmatch ("last", varargin, "exact") > 0; - optrows = strmatch ("rows", varargin, "exact") > 0; + optfirst = ismember ("first", varargin); + optlast = ismember ("last", varargin); + optrows = ismember ("rows", varargin); if (optfirst && optlast) error ('unique: cannot specify both "last" and "first"'); elseif (optfirst + optlast + optrows != nargin-1) @@ -214,3 +214,7 @@ %! assert (A(i,:), a); %! assert (a(j,:), A); +%!error unique({"a", "b", "c"}, "UnknownOption") +%!error unique({"a", "b", "c"}, "UnknownOption1", "UnknownOption2") +%!error unique({"a", "b", "c"}, "rows", "UnknownOption2") +%!error unique({"a", "b", "c"}, "UnknownOption1", "last")