Mercurial > hg > octave-lyh
diff scripts/strings/strtrunc.m @ 8442:502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
author | Thorsten Meyer <thorsten.meyier@gmx.de> |
---|---|
date | Mon, 05 Jan 2009 08:11:03 +0100 |
parents | a1dbe9d80eee |
children | eb63fbe60fab |
line wrap: on
line diff
--- a/scripts/strings/strtrunc.m +++ b/scripts/strings/strtrunc.m @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} strtrunc (@var{s}, @var{n}) ## Truncate the character string @var{s} to length @var{n}. If @var{s} -## is a char matrix, then the number of columns are adjusted. +## is a char matrix, then the number of columns is adjusted. ## ## If @var{s} is a cell array of strings, then the operation is performed ## on its members and the new cell array is returned. @@ -51,3 +51,9 @@ endif endfunction + +%!error <Invalid call to strtrunc> strtrunc (); +%!error <s must be a character string or a cell array of strings> strtrunc (1, 1) +%!assert (strtrunc("abcdefg", 4), "abcd"); +%!assert (strtrunc("abcdefg", 10), "abcdefg"); +%!assert (strtrunc({"abcdef", "fedcba"}, 3), {"abc", "fed"});