annotate scripts/strings/strjust.m @ 30875:5d3faba0342e

doc: Ensure documentation lists output argument when it exists for all m-files. For new users of Octave it is best to show explicit calling forms in the documentation and to show a return argument when it exists. * bp-table.cc, shift.m, accumarray.m, accumdim.m, bincoeff.m, bitcmp.m, bitget.m, bitset.m, blkdiag.m, celldisp.m, cplxpair.m, dblquad.m, flip.m, fliplr.m, flipud.m, idivide.m, int2str.m, interpft.m, logspace.m, num2str.m, polyarea.m, postpad.m, prepad.m, randi.m, repmat.m, rng.m, rot90.m, rotdim.m, structfun.m, triplequad.m, uibuttongroup.m, uicontrol.m, uipanel.m, uipushtool.m, uitoggletool.m, uitoolbar.m, waitforbuttonpress.m, help.m, __additional_help_message__.m, hsv.m, im2double.m, im2frame.m, javachk.m, usejava.m, argnames.m, char.m, formula.m, inline.m, __vectorize__.m, findstr.m, flipdim.m, strmatch.m, vectorize.m, commutation_matrix.m, cond.m, cross.m, duplication_matrix.m, expm.m, orth.m, rank.m, rref.m, trace.m, vech.m, cast.m, compare_versions.m, delete.m, dir.m, fileattrib.m, grabcode.m, gunzip.m, inputname.m, license.m, list_primes.m, ls.m, mexext.m, movefile.m, namelengthmax.m, nargoutchk.m, nthargout.m, substruct.m, swapbytes.m, ver.m, verLessThan.m, what.m, fminunc.m, fsolve.m, fzero.m, optimget.m, __fdjac__.m, matlabroot.m, savepath.m, campos.m, camroll.m, camtarget.m, camup.m, camva.m, camzoom.m, clabel.m, diffuse.m, legend.m, orient.m, rticks.m, specular.m, thetaticks.m, xlim.m, xtickangle.m, xticklabels.m, xticks.m, ylim.m, ytickangle.m, yticklabels.m, yticks.m, zlim.m, ztickangle.m, zticklabels.m, zticks.m, ellipsoid.m, isocolors.m, isonormals.m, stairs.m, surfnorm.m, __actual_axis_position__.m, __pltopt__.m, close.m, graphics_toolkit.m, pan.m, print.m, printd.m, __ghostscript__.m, __gnuplot_print__.m, __opengl_print__.m, rotate3d.m, subplot.m, zoom.m, compan.m, conv.m, poly.m, polyaffine.m, polyder.m, polyint.m, polyout.m, polyreduce.m, polyvalm.m, roots.m, prefdir.m, prefsfile.m, profexplore.m, profexport.m, profshow.m, powerset.m, unique.m, arch_rnd.m, arma_rnd.m, autoreg_matrix.m, bartlett.m, blackman.m, detrend.m, durbinlevinson.m, fftconv.m, fftfilt.m, fftshift.m, fractdiff.m, hamming.m, hanning.m, hurst.m, ifftshift.m, rectangle_lw.m, rectangle_sw.m, triangle_lw.m, sinc.m, sinetone.m, sinewave.m, spectral_adf.m, spectral_xdf.m, spencer.m, ilu.m, __sprand__.m, sprand.m, sprandn.m, sprandsym.m, treelayout.m, beta.m, betainc.m, betaincinv.m, betaln.m, cosint.m, expint.m, factorial.m, gammainc.m, gammaincinv.m, lcm.m, nthroot.m, perms.m, reallog.m, realpow.m, realsqrt.m, sinint.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, pascal.m, rosser.m, toeplitz.m, vander.m, wilkinson.m, center.m, corr.m, cov.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m, discrete_rnd.m, empirical_cdf.m, empirical_inv.m, empirical_pdf.m, empirical_rnd.m, kendall.m, kurtosis.m, mad.m, mean.m, meansq.m, median.m, mode.m, moment.m, range.m, ranks.m, run_count.m, skewness.m, spearman.m, statistics.m, std.m, base2dec.m, bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m, hex2dec.m, index.m, regexptranslate.m, rindex.m, strcat.m, strjust.m, strtrim.m, strtrunc.m, substr.m, untabify.m, __have_feature__.m, __prog_output_assert__.m, __run_test_suite__.m, example.m, fail.m, asctime.m, calendar.m, ctime.m, date.m, etime.m: Add return arguments to @deftypefn macros where they were missing. Rename variables in functions (particularly generic "retval") to match documentation. Rename some return variables for (hopefully) better clarity (e.g., 'ax' to 'hax' to indicate it is a graphics handle to an axes object).
author Rik <rik@octave.org>
date Wed, 30 Mar 2022 20:40:27 -0700
parents 397d29f7135c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
3 ## Copyright (C) 2000-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
7 ##
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
8 ## This file is part of Octave.
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24461
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24461
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
14 ##
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
19 ##
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24461
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
25
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
26 ## -*- texinfo -*-
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30603
diff changeset
27 ## @deftypefn {} {@var{str} =} strjust (@var{s})
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30603
diff changeset
28 ## @deftypefnx {} {@var{str} =} strjust (@var{s}, @var{pos})
11150
564e998017f5 docstring fixes
John W. Eaton <jwe@octave.org>
parents: 11114
diff changeset
29 ## Return the text, @var{s}, justified according to @var{pos}, which may
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
30 ## be @qcode{"left"}, @qcode{"center"}, or @qcode{"right"}.
11096
04c3aacbbc46 strjust.m: Clarify that justification applies to spaces and null characters.
Ben Abbott <bpabbott@mac.com>
parents: 10635
diff changeset
31 ##
20164
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
32 ## If @var{pos} is omitted it defaults to @qcode{"right"}.
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
33 ##
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
34 ## Null characters are replaced by spaces. All other character data are
df437a52bcaf doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
35 ## treated as non-white space.
11096
04c3aacbbc46 strjust.m: Clarify that justification applies to spaces and null characters.
Ben Abbott <bpabbott@mac.com>
parents: 10635
diff changeset
36 ##
04c3aacbbc46 strjust.m: Clarify that justification applies to spaces and null characters.
Ben Abbott <bpabbott@mac.com>
parents: 10635
diff changeset
37 ## Example:
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
38 ##
8442
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7017
diff changeset
39 ## @example
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7017
diff changeset
40 ## @group
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7017
diff changeset
41 ## strjust (["a"; "ab"; "abc"; "abcd"])
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
42 ## @result{}
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
43 ## " a"
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
44 ## " ab"
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
45 ## " abc"
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
46 ## "abcd"
8442
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7017
diff changeset
47 ## @end group
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7017
diff changeset
48 ## @end example
11114
f7079e3b0227 strjust.m: Add "untabify" and "strrep" to @seealso{} in the doc-string.
Ben Abbott <bpabbott@mac.com>
parents: 11096
diff changeset
49 ## @seealso{deblank, strrep, strtrim, untabify}
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
50 ## @end deftypefn
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
51
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30603
diff changeset
52 function str = strjust (s, pos = "right")
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
53
28789
28de41192f3c Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents: 28564
diff changeset
54 if (nargin < 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5568
diff changeset
55 print_usage ();
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
56 elseif (! ischar (s) || ndims (s) > 2)
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
57 error ("strjust: S must be a string or 2-D character matrix");
10018
fb8834c12035 fix & improve strjust
Jaroslav Hajek <highegg@gmail.com>
parents: 9036
diff changeset
58 endif
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
59
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11150
diff changeset
60 if (isempty (s))
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30603
diff changeset
61 str = s;
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
62 return;
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
63 endif
10020
ffee051323f8 rewrite strjust
Jaroslav Hajek <highegg@gmail.com>
parents: 10018
diff changeset
64
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
65 ## Apparently, Matlab considers nulls to be blanks as well; however, does
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
66 ## not preserve the nulls, but rather converts them to blanks. That's a
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
67 ## bit unexpected, but it allows simpler processing, because we can move
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 20852
diff changeset
68 ## just the nonblank characters. So we'll do the same here.
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
69
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
70 [nr, nc] = size (s);
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
71 ## Find the indices of all nonblanks.
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
72 nonbl = s != " " & s != "\0";
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
73 [idx, jdx] = find (nonbl);
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
74
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
75 if (strcmpi (pos, "right"))
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 20852
diff changeset
76 ## We wish to find the maximum column index for each row. Because jdx is
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
77 ## sorted, we can take advantage of the fact that assignment is processed
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
78 ## sequentially and for duplicate indices the last value will remain.
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
79 maxs = repmat (nc, [nr, 1]);
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
80 maxs(idx) = jdx;
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
81 shift = nc - maxs;
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
82 elseif (strcmpi (pos, "left"))
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
83 ## See above for explanation.
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
84 mins = ones (nr, 1);
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
85 mins(flipud (idx(:))) = flipud (jdx(:));
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
86 shift = 1 - mins;
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
87 else
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
88 ## Use both of the above to achieve centering.
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
89 mins = ones (nr, 1);
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
90 mins(flipud (idx(:))) = flipud (jdx(:));
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
91 maxs = repmat (nc, [nr, 1]);
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
92 maxs(idx) = jdx;
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
93 shift = floor ((nc + 1 - maxs - mins) / 2);
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
94 endif
10018
fb8834c12035 fix & improve strjust
Jaroslav Hajek <highegg@gmail.com>
parents: 9036
diff changeset
95
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
96 ## Adjust the column indices.
30603
397d29f7135c shift.m: Deprecate function in favor of circshift for Matlab compatibility.
Rik <rik@octave.org>
parents: 30564
diff changeset
97 jdx += shift(idx);
10018
fb8834c12035 fix & improve strjust
Jaroslav Hajek <highegg@gmail.com>
parents: 9036
diff changeset
98
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
99 ## Create a blank matrix and position the nonblank characters.
30875
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30603
diff changeset
100 str = repmat (" ", nr, nc);
5d3faba0342e doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents: 30603
diff changeset
101 str(sub2ind ([nr, nc], idx, jdx)) = s(nonbl);
3789
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
102
2a257be5e488 [project @ 2001-02-09 04:12:30 by jwe]
jwe
parents:
diff changeset
103 endfunction
8442
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7017
diff changeset
104
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
105
24461
0a034d34a686 Modify BIST tests to pass when string_fill_char is not ' '.
Rik <rik@octave.org>
parents: 23220
diff changeset
106 %!assert (strjust (char ("a", "ab", "abc", "abcd")),
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
107 %! [" a";" ab"; " abc"; "abcd"])
24461
0a034d34a686 Modify BIST tests to pass when string_fill_char is not ' '.
Rik <rik@octave.org>
parents: 23220
diff changeset
108 %!assert (strjust (char (" a", " ab", "abc", "abcd"), "left"),
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
109 %! ["a "; "ab "; "abc "; "abcd"])
24461
0a034d34a686 Modify BIST tests to pass when string_fill_char is not ' '.
Rik <rik@octave.org>
parents: 23220
diff changeset
110 %!assert (strjust (char ("a", "ab", "abc", "abcd"), "CENTER"),
0a034d34a686 Modify BIST tests to pass when string_fill_char is not ' '.
Rik <rik@octave.org>
parents: 23220
diff changeset
111 %! [" a "; " ab "; "abc "; "abcd"])
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
112 %!assert (strjust (["";""]), "")
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
113
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
114 ## Test input validation
13318
f3b665972bb5 strjust.m: Tweak code for performance. Add more input validation and tests.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
115 %!error <Invalid call to strjust> strjust ()
28564
1dd765e54265 fix tests for new argument number mismatch error message
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
116 %!error <called with too many inputs> strjust (["a";"ab"], "center", 1)
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
117 %!error <S must be a string> strjust (ones (3,3))
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
118 %!error <S must be a string> strjust (char (ones (3,3,3)))