7017
|
1 ## Copyright (C) 2006, 2007 John W. Eaton |
7016
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
|
18 |
5590
|
19 %% Automatically generated from DejaGNU files |
|
20 |
|
21 %% test/octave.test/string/str-esc-1.m |
|
22 %!test |
|
23 %! x = 7; |
|
24 %! if (strcmp ("\a", setstr (x))) |
|
25 %! printf_assert ("ok\n"); |
|
26 %! endif |
|
27 %! assert(prog_output_assert("ok")); |
|
28 |
|
29 %% test/octave.test/string/str-esc-2.m |
|
30 %!test |
|
31 %! x = 8; |
|
32 %! if (strcmp ("\b", setstr (x))) |
|
33 %! printf_assert ("ok\n"); |
|
34 %! endif |
|
35 %! assert(prog_output_assert("ok")); |
|
36 |
|
37 %% test/octave.test/string/str-esc-3.m |
|
38 %!test |
|
39 %! x = 12; |
|
40 %! if (strcmp ("\f", setstr (x))) |
|
41 %! printf_assert ("ok\n"); |
|
42 %! endif |
|
43 %! assert(prog_output_assert("ok")); |
|
44 |
|
45 %% test/octave.test/string/str-esc-4.m |
|
46 %!test |
|
47 %! x = 10; |
|
48 %! if (strcmp ("\n", setstr (x))) |
|
49 %! printf_assert ("ok\n"); |
|
50 %! endif |
|
51 %! assert(prog_output_assert("ok")); |
|
52 |
|
53 %% test/octave.test/string/str-esc-5.m |
|
54 %!test |
|
55 %! x = 13; |
|
56 %! if (strcmp ("\r", setstr (x))) |
|
57 %! printf_assert ("ok\n"); |
|
58 %! endif |
|
59 %! assert(prog_output_assert("ok")); |
|
60 |
|
61 %% test/octave.test/string/str-esc-6.m |
|
62 %!test |
|
63 %! x = 9; |
|
64 %! if (strcmp ("\t", setstr (x))) |
|
65 %! printf_assert ("ok\n"); |
|
66 %! endif |
|
67 %! assert(prog_output_assert("ok")); |
|
68 |
|
69 %% test/octave.test/string/str-esc-7.m |
|
70 %!test |
|
71 %! x = 11; |
|
72 %! if (strcmp ("\v", setstr (x))) |
|
73 %! printf_assert ("ok\n"); |
|
74 %! endif |
|
75 %! assert(prog_output_assert("ok")); |
|
76 |
|
77 %% test/octave.test/string/str-esc-8.m |
|
78 %!test |
|
79 %! x = 92; |
|
80 %! if (strcmp ("\\", setstr (x))) |
|
81 %! printf_assert ("ok\n"); |
|
82 %! endif |
|
83 %! assert(prog_output_assert("ok")); |
|
84 |
|
85 %% test/octave.test/string/str-esc-9.m |
|
86 %!test |
|
87 %! x = 39; |
|
88 %! if (strcmp ("\'", setstr (x))) |
|
89 %! printf_assert ("ok\n"); |
|
90 %! endif |
|
91 %! assert(prog_output_assert("ok")); |
|
92 |
|
93 %% test/octave.test/string/str-esc-10.m |
|
94 %!test |
|
95 %! x = 34; |
|
96 %! if (strcmp ("\"", setstr (x))) |
|
97 %! printf_assert ("ok\n"); |
|
98 %! endif |
|
99 %! assert(prog_output_assert("ok")); |
|
100 |
|
101 %% test/octave.test/string/str-esc-11.m |
|
102 %!test |
|
103 %! x = 120; |
|
104 %! fail('strcmp ("\x", setstr (x))',"warning",".*unrecognized escape sequence.*"); |
|
105 |
|
106 %% test/octave.test/string/str-esc-12.m |
|
107 %!test |
|
108 %! x = [7, 8, 12, 10, 13, 9, 11, 92, 39, 34]; |
|
109 %! if (strcmp ("\a\b\f\n\r\t\v\\\'\"", setstr (x))) |
|
110 %! printf_assert ("ok\n"); |
|
111 %! endif |
|
112 %! assert(prog_output_assert("ok")); |
|
113 |
5775
|
114 %% FIXME |
5590
|
115 %% Why do the next two tests fail? |
|
116 %% test/octave.test/string/string_fill_char-1.m |
|
117 %!#test |
|
118 %! sfc = string_fill_char; |
|
119 %! string_fill_char = "X"; |
|
120 %! str = ["these"; "are"; "strings"]; |
|
121 %! assert(str,["theseXX"; "areXXXX"; "strings"]); |
|
122 %! string_fill_char = sfc; |
|
123 |
|
124 %% test/octave.test/string/string_fill_char-2.m |
|
125 %!#test |
|
126 %! sfc = string_fill_char; |
|
127 %! string_fill_char = " "; |
|
128 %! str = ["these"; "are"; "strings"]; |
|
129 %! assert(str,["these "; "are "; "strings"]); |
|
130 %! string_fill_char = sfc; |
|
131 |
|
132 %% test/octave.test/string/ischar-1.m |
|
133 %!assert(!(ischar (1))); |
|
134 |
|
135 %% test/octave.test/string/ischar-2.m |
|
136 %!assert(!(ischar ([1, 2]))); |
|
137 |
|
138 %% test/octave.test/string/ischar-3.m |
|
139 %!assert(!(ischar ([]))); |
|
140 |
|
141 %% test/octave.test/string/ischar-4.m |
|
142 %!assert(!(ischar ([1, 2; 3, 4]))); |
|
143 |
|
144 %% test/octave.test/string/ischar-5.m |
|
145 %!assert(ischar ("")); |
|
146 |
|
147 %% test/octave.test/string/ischar-6.m |
|
148 %!assert(ischar ("t")); |
|
149 |
|
150 %% test/octave.test/string/ischar-7.m |
|
151 %!assert(ischar ("test")); |
|
152 |
|
153 %% test/octave.test/string/ischar-8.m |
|
154 %!assert(ischar (["test"; "ing"])); |
|
155 |
|
156 %% test/octave.test/string/ischar-9.m |
|
157 %!test |
|
158 %! s.a = "test"; |
|
159 %! assert(!(ischar (s))); |
|
160 |
|
161 %% test/octave.test/string/ischar-10.m |
5751
|
162 %!error <Invalid call to ischar.*> ischar (); |
5590
|
163 |
|
164 %% test/octave.test/string/ischar-11.m |
5751
|
165 %!error <Invalid call to ischar.*> ischar ("test", 1); |
5590
|
166 |
|
167 |
|
168 %% test/octave.test/string/char-1.m |
|
169 %!assert(strcmp (char ([65, 83, 67, 73, 73]), "ASCII")); |
|
170 |
|
171 %% test/octave.test/string/char-2.m |
5751
|
172 %!error <Invalid call to char.*> char (); |
5590
|
173 |
|
174 %% test/octave.test/string/char-3.m |
|
175 %!test |
|
176 %! x = char ("foo", "bar", "foobar"); |
|
177 %! assert((strcmp (x(1,:), "foo ") |
|
178 %! && strcmp (x(2,:), "bar ") |
|
179 %! && strcmp (x(3,:), "foobar"))); |
|
180 |
|
181 |
|
182 %% test/octave.test/string/strcmp-1.m |
|
183 %!assert(strcmp ("foobar", "foobar") && strcmp ("fooba", "foobar") == 0); |
|
184 |
|
185 %% test/octave.test/string/strcmp-2.m |
5751
|
186 %!error <Invalid call to strcmp.*> strcmp (); |
5590
|
187 |
|
188 %% test/octave.test/string/strcmp-3.m |
5751
|
189 %!error <Invalid call to strcmp.*> strcmp ("foo", "bar", 3); |
5590
|
190 |
|
191 |
|
192 |
|
193 %% test/octave.test/string/undo_string_escapes-1.m |
|
194 %!assert(strcmp (undo_string_escapes ("abc\a\b\n\r\t\v\f123"), |
|
195 %! "abc\\a\\b\\n\\r\\t\\v\\f123")); |
|
196 |
|
197 %% test/octave.test/string/undo_string_escapes-2.m |
5751
|
198 %!error <Invalid call to undo_string_escapes.*> undo_string_escapes (); |
5590
|
199 |
|
200 %% test/octave.test/string/undo_string_escapes-3.m |
5751
|
201 %!error <Invalid call to undo_string_escapes.*> undo_string_escapes ("string", 2); |
5590
|
202 |
|
203 %% test/octave.test/string/toascii-1.m |
|
204 %!test |
|
205 %! charset = setstr (0:127); |
|
206 %! |
|
207 %! result = 0:127; |
|
208 %! |
|
209 %! assert(all (toascii (charset) == result)); |
|
210 |
|
211 %% test/octave.test/string/toascii-3.m |
|
212 %!error toascii (1, 2); |
|
213 |
|
214 %% test/octave.test/string/toascii-3.m |
|
215 %!error toascii (1, 2); |
|
216 |
|
217 %% test/octave.test/string/tolower-1.m |
|
218 %!test |
|
219 %! charset = setstr (0:127); |
|
220 %! |
|
221 %! result = charset; |
|
222 %! |
|
223 %! result ((toascii("A"):toascii("Z"))+1) \ |
|
224 %! = result ((toascii("a"):toascii("z"))+1); |
|
225 %! |
|
226 %! assert(all (tolower (charset) == result)); |
|
227 |
|
228 %% test/octave.test/string/tolower-3.m |
|
229 %!error tolower (1, 2); |
|
230 |
|
231 %% test/octave.test/string/tolower-3.m |
|
232 %!error tolower (1, 2); |
|
233 |
|
234 %% test/octave.test/string/toupper-1.m |
|
235 %!test |
|
236 %! charset = setstr (0:127); |
|
237 %! |
|
238 %! result = charset; |
|
239 %! |
|
240 %! result ((toascii("a"):toascii("z"))+1) \ |
|
241 %! = result ((toascii("A"):toascii("Z"))+1); |
|
242 %! |
|
243 %! assert(all (toupper (charset) == result)); |
|
244 |
|
245 %% test/octave.test/string/toupper-3.m |
|
246 %!error toupper (1, 2); |
|
247 |
|
248 %% test/octave.test/string/toupper-3.m |
|
249 %!error toupper (1, 2); |
|
250 |
|
251 %% test/octave.test/string/isalnum-1.m |
|
252 %!test |
|
253 %! charset = setstr (0:127); |
|
254 %! |
|
255 %! result = zeros (1, 128); |
|
256 %! |
|
257 %! result ((toascii("A"):toascii("Z"))+1) = 1; |
|
258 %! result ((toascii("0"):toascii("9"))+1) = 1; |
|
259 %! result ((toascii("a"):toascii("z"))+1) = 1; |
|
260 %! |
|
261 %! assert(all (isalnum (charset) == result)); |
|
262 |
|
263 %% test/octave.test/string/isalnum-2.m |
|
264 %!error isalnum (1, 2); |
|
265 |
|
266 %% test/octave.test/string/isalnum-3.m |
|
267 %!error isalnum (); |
|
268 |
|
269 %% test/octave.test/string/isalpha-1.m |
|
270 %!test |
|
271 %! charset = setstr (0:127); |
|
272 %! |
|
273 %! result = zeros (1, 128); |
|
274 %! |
|
275 %! result ((toascii("A"):toascii("Z"))+1) = 1; |
|
276 %! result ((toascii("a"):toascii("z"))+1) = 1; |
|
277 %! |
|
278 %! assert(all (isalpha (charset) == result)); |
|
279 |
|
280 %% test/octave.test/string/isalpha-2.m |
|
281 %!error isalpha (1, 2); |
|
282 |
|
283 %% test/octave.test/string/isalpha-3.m |
|
284 %!error isalpha (); |
|
285 |
|
286 %% test/octave.test/string/isascii-1.m |
|
287 %!test |
|
288 %! charset = setstr (0:127); |
|
289 %! |
|
290 %! result = ones (1, 128); |
|
291 %! |
|
292 %! assert(all (isascii (charset) == result)); |
|
293 |
|
294 %% test/octave.test/string/isascii-2.m |
|
295 %!error isascii (1, 2); |
|
296 |
|
297 %% test/octave.test/string/isascii-3.m |
|
298 %!error isascii (); |
|
299 |
|
300 %% test/octave.test/string/iscntrl-1.m |
|
301 %!test |
|
302 %! charset = setstr (0:127); |
|
303 %! |
|
304 %! result = zeros (1, 128); |
|
305 %! |
|
306 %! result (1:32) = 1; |
|
307 %! result (128) = 1; |
|
308 %! |
|
309 %! assert(all (iscntrl (charset) == result)); |
|
310 |
|
311 %% test/octave.test/string/iscntrl-2.m |
|
312 %!error iscntrl (1, 2); |
|
313 |
|
314 %% test/octave.test/string/iscntrl-3.m |
|
315 %!error iscntrl (); |
|
316 |
|
317 %% test/octave.test/string/isdigit-1.m |
|
318 %!test |
|
319 %! charset = setstr (0:127); |
|
320 %! |
|
321 %! result = zeros (1, 128); |
|
322 %! |
|
323 %! result ((toascii("0"):toascii("9"))+1) = 1; |
|
324 %! |
|
325 %! assert(all (isdigit (charset) == result)); |
|
326 |
|
327 %% test/octave.test/string/isdigit-2.m |
|
328 %!error isdigit (1, 2); |
|
329 |
|
330 %% test/octave.test/string/isdigit-3.m |
|
331 %!error isdigit (); |
|
332 |
|
333 %% test/octave.test/string/isgraph-1.m |
|
334 %!test |
|
335 %! charset = setstr (0:127); |
|
336 %! |
|
337 %! result = zeros (1, 128); |
|
338 %! |
|
339 %! result (34:127) = 1; |
|
340 %! |
|
341 %! assert(all (isgraph (charset) == result)); |
|
342 |
|
343 %% test/octave.test/string/isgraph-2.m |
|
344 %!error isgraph (1, 2); |
|
345 |
|
346 %% test/octave.test/string/isgraph-3.m |
|
347 %!error isgraph (); |
|
348 |
|
349 %% test/octave.test/string/islower-1.m |
|
350 %!test |
|
351 %! charset = setstr (0:127); |
|
352 %! |
|
353 %! result = zeros (1, 128); |
|
354 %! |
|
355 %! result ((toascii("a"):toascii("z"))+1) = 1; |
|
356 %! |
|
357 %! assert(all (islower (charset) == result)); |
|
358 |
|
359 %% test/octave.test/string/islower-2.m |
|
360 %!error islower (1, 2); |
|
361 |
|
362 %% test/octave.test/string/islower-3.m |
|
363 %!error islower (); |
|
364 |
|
365 %% test/octave.test/string/isprint-1.m |
|
366 %!test |
|
367 %! charset = setstr (0:127); |
|
368 %! |
|
369 %! result = zeros (1, 128); |
|
370 %! |
|
371 %! result (33:127) = 1; |
|
372 %! |
|
373 %! assert(all (isprint (charset) == result)); |
|
374 |
|
375 %% test/octave.test/string/isprint-2.m |
|
376 %!error isprint (1, 2); |
|
377 |
|
378 %% test/octave.test/string/isprint-3.m |
|
379 %!error isprint (); |
|
380 |
|
381 %% test/octave.test/string/ispunct-1.m |
|
382 %!test |
|
383 %! charset = setstr (0:127); |
|
384 %! |
|
385 %! result = zeros (1, 128); |
|
386 %! |
|
387 %! result (34:48) = 1; |
|
388 %! result (59:65) = 1; |
|
389 %! result (92:97) = 1; |
|
390 %! result (124:127) = 1; |
|
391 %! |
|
392 %! assert(all (ispunct (charset) == result)); |
|
393 |
|
394 %% test/octave.test/string/ispunct-2.m |
|
395 %!error ispunct (1, 2); |
|
396 |
|
397 %% test/octave.test/string/ispunct-3.m |
|
398 %!error ispunct (); |
|
399 |
|
400 %% test/octave.test/string/isspace-1.m |
|
401 %!test |
|
402 %! charset = setstr (0:127); |
|
403 %! |
|
404 %! result = zeros (1, 128); |
|
405 %! |
|
406 %! result (toascii (" \f\n\r\t\v")+1) = 1; |
|
407 %! |
|
408 %! assert(all (isspace (charset) == result)); |
|
409 |
|
410 %% test/octave.test/string/isspace-2.m |
|
411 %!error isspace (1, 2); |
|
412 |
|
413 %% test/octave.test/string/isspace-3.m |
|
414 %!error isspace (); |
|
415 |
|
416 %% test/octave.test/string/isupper-1.m |
|
417 %!test |
|
418 %! charset = setstr (0:127); |
|
419 %! |
|
420 %! result = zeros (1, 128); |
|
421 %! |
|
422 %! result ((toascii("A"):toascii("Z"))+1) = 1; |
|
423 %! |
|
424 %! assert(all (isupper (charset) == result)); |
|
425 |
|
426 %% test/octave.test/string/isupper-2.m |
|
427 %!error isupper (1, 2); |
|
428 |
|
429 %% test/octave.test/string/isupper-3.m |
|
430 %!error isupper (); |
|
431 |
|
432 %% test/octave.test/string/isxdigit-1.m |
|
433 %!test |
|
434 %! charset = setstr (0:127); |
|
435 %! |
|
436 %! result = zeros (1, 128); |
|
437 %! |
|
438 %! result ((toascii("A"):toascii("F"))+1) = 1; |
|
439 %! result ((toascii("0"):toascii("9"))+1) = 1; |
|
440 %! result ((toascii("a"):toascii("f"))+1) = 1; |
|
441 %! |
|
442 %! assert(all (isxdigit (charset) == result)); |
|
443 |
|
444 %% test/octave.test/string/isxdigit-2.m |
|
445 %!error isxdigit (1, 2); |
|
446 |
|
447 %% test/octave.test/string/isxdigit-3.m |
|
448 %!error isxdigit (); |
|
449 |