Mercurial > hg > octave-lyh
comparison scripts/strings/cstrcat.m @ 13841:0a158dbdb04a
Remove 3 unused warning ids
Removed ids: empty-list-elements, fortran-indexing, complex-cmp-ops.
Renamed ids: string-concat -> mixed-string-concat
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 08 Nov 2011 09:07:13 -0800 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
13840:69afe121f07e | 13841:0a158dbdb04a |
---|---|
42 | 42 |
43 ## Author: jwe | 43 ## Author: jwe |
44 | 44 |
45 function st = cstrcat (varargin) | 45 function st = cstrcat (varargin) |
46 | 46 |
47 if (nargin > 0) | 47 if (nargin < 1) |
48 print_usage (); | |
49 elseif (! iscellstr (varargin)) | |
50 error ("cstrcat: expecting arguments to character strings"); | |
51 endif | |
48 | 52 |
49 if (iscellstr (varargin)) | 53 st = [varargin{:}]; |
50 ## All arguments are character strings. | |
51 unwind_protect | |
52 tmp = warning ("query", "Octave:empty-list-elements"); | |
53 warning ("off", "Octave:empty-list-elements"); | |
54 st = [varargin{:}]; | |
55 unwind_protect_cleanup | |
56 warning (tmp.state, "Octave:empty-list-elements"); | |
57 end_unwind_protect | |
58 else | |
59 error ("cstrcat: expecting arguments to character strings"); | |
60 endif | |
61 else | |
62 print_usage (); | |
63 endif | |
64 | 54 |
65 endfunction | 55 endfunction |
66 | 56 |
67 ## test the dimensionality | 57 |
58 ## Test the dimensionality | |
68 ## 1d | 59 ## 1d |
69 %!assert(cstrcat("ab ", "ab "), "ab ab ") | 60 %!assert (cstrcat ("ab ", "ab "), "ab ab ") |
70 ## 2d | 61 ## 2d |
71 %!assert(cstrcat(["ab ";"cde"], ["ab ";"cde"]), ["ab ab ";"cdecde"]) | 62 %!assert (cstrcat (["ab ";"cde"], ["ab ";"cde"]), ["ab ab ";"cdecde"]) |
72 | 63 |
73 %!assert((strcmp (cstrcat ("foo", "bar"), "foobar") | 64 %!assert (cstrcat ("foo", "bar"), "foobar") |
74 %! && strcmp (cstrcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"]))); | 65 %!assert (cstrcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"]) |
75 | 66 |
67 %% Test input validation | |
76 %!error cstrcat (); | 68 %!error cstrcat (); |
77 | |
78 %!error cstrcat (1, 2); | 69 %!error cstrcat (1, 2); |
79 | 70 |