comparison test/test_string.m @ 5590:1ad66ea35fe5

[project @ 2006-01-06 00:24:05 by jwe]
author jwe
date Fri, 06 Jan 2006 00:24:06 +0000
parents
children 02c7e288f581
comparison
equal deleted inserted replaced
5589:f812a0680d05 5590:1ad66ea35fe5
1 %% Automatically generated from DejaGNU files
2
3 %% test/octave.test/string/str-esc-1.m
4 %!test
5 %! x = 7;
6 %! if (strcmp ("\a", setstr (x)))
7 %! printf_assert ("ok\n");
8 %! endif
9 %! assert(prog_output_assert("ok"));
10
11 %% test/octave.test/string/str-esc-2.m
12 %!test
13 %! x = 8;
14 %! if (strcmp ("\b", setstr (x)))
15 %! printf_assert ("ok\n");
16 %! endif
17 %! assert(prog_output_assert("ok"));
18
19 %% test/octave.test/string/str-esc-3.m
20 %!test
21 %! x = 12;
22 %! if (strcmp ("\f", setstr (x)))
23 %! printf_assert ("ok\n");
24 %! endif
25 %! assert(prog_output_assert("ok"));
26
27 %% test/octave.test/string/str-esc-4.m
28 %!test
29 %! x = 10;
30 %! if (strcmp ("\n", setstr (x)))
31 %! printf_assert ("ok\n");
32 %! endif
33 %! assert(prog_output_assert("ok"));
34
35 %% test/octave.test/string/str-esc-5.m
36 %!test
37 %! x = 13;
38 %! if (strcmp ("\r", setstr (x)))
39 %! printf_assert ("ok\n");
40 %! endif
41 %! assert(prog_output_assert("ok"));
42
43 %% test/octave.test/string/str-esc-6.m
44 %!test
45 %! x = 9;
46 %! if (strcmp ("\t", setstr (x)))
47 %! printf_assert ("ok\n");
48 %! endif
49 %! assert(prog_output_assert("ok"));
50
51 %% test/octave.test/string/str-esc-7.m
52 %!test
53 %! x = 11;
54 %! if (strcmp ("\v", setstr (x)))
55 %! printf_assert ("ok\n");
56 %! endif
57 %! assert(prog_output_assert("ok"));
58
59 %% test/octave.test/string/str-esc-8.m
60 %!test
61 %! x = 92;
62 %! if (strcmp ("\\", setstr (x)))
63 %! printf_assert ("ok\n");
64 %! endif
65 %! assert(prog_output_assert("ok"));
66
67 %% test/octave.test/string/str-esc-9.m
68 %!test
69 %! x = 39;
70 %! if (strcmp ("\'", setstr (x)))
71 %! printf_assert ("ok\n");
72 %! endif
73 %! assert(prog_output_assert("ok"));
74
75 %% test/octave.test/string/str-esc-10.m
76 %!test
77 %! x = 34;
78 %! if (strcmp ("\"", setstr (x)))
79 %! printf_assert ("ok\n");
80 %! endif
81 %! assert(prog_output_assert("ok"));
82
83 %% test/octave.test/string/str-esc-11.m
84 %!test
85 %! x = 120;
86 %! fail('strcmp ("\x", setstr (x))',"warning",".*unrecognized escape sequence.*");
87
88 %% test/octave.test/string/str-esc-12.m
89 %!test
90 %! x = [7, 8, 12, 10, 13, 9, 11, 92, 39, 34];
91 %! if (strcmp ("\a\b\f\n\r\t\v\\\'\"", setstr (x)))
92 %! printf_assert ("ok\n");
93 %! endif
94 %! assert(prog_output_assert("ok"));
95
96 %% XXX FIXME XXX
97 %% Why do the next two tests fail?
98 %% test/octave.test/string/string_fill_char-1.m
99 %!#test
100 %! sfc = string_fill_char;
101 %! string_fill_char = "X";
102 %! str = ["these"; "are"; "strings"];
103 %! assert(str,["theseXX"; "areXXXX"; "strings"]);
104 %! string_fill_char = sfc;
105
106 %% test/octave.test/string/string_fill_char-2.m
107 %!#test
108 %! sfc = string_fill_char;
109 %! string_fill_char = " ";
110 %! str = ["these"; "are"; "strings"];
111 %! assert(str,["these "; "are "; "strings"]);
112 %! string_fill_char = sfc;
113
114 %% test/octave.test/string/ischar-1.m
115 %!assert(!(ischar (1)));
116
117 %% test/octave.test/string/ischar-2.m
118 %!assert(!(ischar ([1, 2])));
119
120 %% test/octave.test/string/ischar-3.m
121 %!assert(!(ischar ([])));
122
123 %% test/octave.test/string/ischar-4.m
124 %!assert(!(ischar ([1, 2; 3, 4])));
125
126 %% test/octave.test/string/ischar-5.m
127 %!assert(ischar (""));
128
129 %% test/octave.test/string/ischar-6.m
130 %!assert(ischar ("t"));
131
132 %% test/octave.test/string/ischar-7.m
133 %!assert(ischar ("test"));
134
135 %% test/octave.test/string/ischar-8.m
136 %!assert(ischar (["test"; "ing"]));
137
138 %% test/octave.test/string/ischar-9.m
139 %!test
140 %! s.a = "test";
141 %! assert(!(ischar (s)));
142
143 %% test/octave.test/string/ischar-10.m
144 %!error <... ischar:.*> ischar ();
145
146 %% test/octave.test/string/ischar-11.m
147 %!error <... ischar:.*> ischar ("test", 1);
148
149 %% test/octave.test/string/blanks-1.m
150 %!assert(strcmp (blanks (3), " "));
151
152 %% test/octave.test/string/blanks-2.m
153 %!error blanks ();
154
155 %% test/octave.test/string/blanks-3.m
156 %!error blanks (1, 2);
157
158 %% test/octave.test/string/char-1.m
159 %!assert(strcmp (char ([65, 83, 67, 73, 73]), "ASCII"));
160
161 %% test/octave.test/string/char-2.m
162 %!error <... char:.*> char ();
163
164 %% test/octave.test/string/char-3.m
165 %!test
166 %! x = char ("foo", "bar", "foobar");
167 %! assert((strcmp (x(1,:), "foo ")
168 %! && strcmp (x(2,:), "bar ")
169 %! && strcmp (x(3,:), "foobar")));
170
171 %% test/octave.test/string/int2str-1.m
172 %!assert(strcmp (int2str (-123), "-123") && strcmp (int2str (1.2), "1"));
173
174 %% test/octave.test/string/int2str-2.m
175 %!error int2str ();
176
177 %% test/octave.test/string/int2str-3.m
178 %!error int2str (1, 2);
179
180 %% test/octave.test/string/num2str-1.m
181 %!assert((strcmp (num2str (123), "123") && strcmp (num2str (1.23), "1.23")));
182
183 %% test/octave.test/string/num2str-2.m
184 %!error num2str ();
185
186 %% test/octave.test/string/num2str-3.m
187 %!error num2str (1, 2, 3);
188
189 %% test/octave.test/string/strcat-1.m
190 %!assert((strcmp (strcat ("foo", "bar"), "foobar")
191 %! && strcmp (strcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"])));
192
193 %% test/octave.test/string/strcat-2.m
194 %!error strcat ();
195
196 %% test/octave.test/string/strcat-3.m
197 %!error strcat (1, 2);
198
199 %% test/octave.test/string/str2mat-1.m
200 %!assert(strcmp (str2mat ("a", "bb", "ccc"), ["a "; "bb "; "ccc"]));
201
202 %% test/octave.test/string/str2mat-2.m
203 %!error str2mat ();
204
205 %% test/octave.test/string/str2mat-3.m
206 %!assert(all (str2mat (1, 2, 3) == setstr ([1; 2; 3])));
207
208 %% test/octave.test/string/deblank-1.m
209 %!assert(strcmp (deblank (" f o o "), " f o o"));
210
211 %% test/octave.test/string/deblank-2.m
212 %!error deblank ();
213
214 %% test/octave.test/string/deblank-3.m
215 %!error deblank ("foo", "bar");
216
217 %% test/octave.test/string/deblank-4.m
218 %!error deblank (1);
219
220 %% test/octave.test/string/findstr-1.m
221 %!assert((findstr ("abababa", "a") == [1, 3, 5, 7]
222 %! && findstr ("abababa", "aba") == [1, 3, 5]
223 %! && findstr ("abababa", "aba", 0) == [1, 5]));
224
225 %% test/octave.test/string/findstr-2.m
226 %!error findstr ();
227
228 %% test/octave.test/string/findstr-3.m
229 %!error findstr ("foo", "bar", 3, 4);
230
231 %% test/octave.test/string/index-1.m
232 %!assert(index ("foobarbaz", "b") == 4 && index ("foobarbaz", "z") == 9);
233
234 %% test/octave.test/string/index-2.m
235 %!error index ();
236
237 %% test/octave.test/string/index-3.m
238 %!error index ("foo", "bar", 3);
239
240 %% test/octave.test/string/rindex-1.m
241 %!assert(rindex ("foobarbaz", "b") == 7 && rindex ("foobarbaz", "o") == 3);
242
243 %% test/octave.test/string/rindex-2.m
244 %!error rindex ();
245
246 %% test/octave.test/string/rindex-3.m
247 %!error rindex ("foo", "bar", 3);
248
249 %% test/octave.test/string/split-1.m
250 %!assert(all (all (split ("Test string", "t") == ["Tes "; " s "; "ring"])));
251
252 %% test/octave.test/string/split-2.m
253 %!error split ();
254
255 %% test/octave.test/string/split-3.m
256 %!assert(all (strcmp (split ("foo bar baz", " ", 2), ["foo"; "bar baz"])));
257
258 %% test/octave.test/string/split-4.m
259 %!error split ("foo", "bar", 3, 4);
260
261 %% test/octave.test/string/strrep-1.m
262 %!assert(strcmp (strrep ("This is a test string", "is", "&%$"),
263 %! "Th&%$ &%$ a test string"));
264
265 %% test/octave.test/string/strrep-2.m
266 %!error strrep ();
267
268 %% test/octave.test/string/strrep-3.m
269 %!error strrep ("foo", "bar", 3, 4);
270
271 %% test/octave.test/string/substr-1.m
272 %!assert(strcmp (substr ("This is a test string", 6, 9), "is a test"));
273
274 %% test/octave.test/string/substr-2.m
275 %!error substr ();
276
277 %% test/octave.test/string/substr-3.m
278 %!error substr ("foo", 2, 3, 4);
279
280 %% test/octave.test/string/strcmp-1.m
281 %!assert(strcmp ("foobar", "foobar") && strcmp ("fooba", "foobar") == 0);
282
283 %% test/octave.test/string/strcmp-2.m
284 %!error <... strcmp:.*> strcmp ();
285
286 %% test/octave.test/string/strcmp-3.m
287 %!error <... strcmp:.*> strcmp ("foo", "bar", 3);
288
289 %% test/octave.test/string/bin2dec-1.m
290 %!assert(bin2dec ("1110") == 14);
291
292 %% test/octave.test/string/bin2dec-2.m
293 %!error bin2dec ();
294
295 %% test/octave.test/string/bin2dec-3.m
296 %!error bin2dec ("str", 1);
297
298 %% test/octave.test/string/dec2bin-1.m
299 %!assert(strcmp (dec2bin (14), "1110"));
300
301 %% test/octave.test/string/dec2bin-2.m
302 %!error dec2bin ();
303
304 %% test/octave.test/string/dec2bin-3.m
305 %!assert(strcmp (dec2bin (14, 6), "001110")
306 %! );
307
308 %% test/octave.test/string/dec2bin-4.m
309 %!error dec2bin (1, 2, 3);
310
311 %% test/octave.test/string/dec2hex-1.m
312 %!assert(strcmp (tolower (dec2hex (2748)), "abc"));
313
314 %% test/octave.test/string/dec2hex-2.m
315 %!error dec2hex ();
316
317 %% test/octave.test/string/dec2hex-3.m
318 %!assert(strcmp (tolower (dec2hex (2748, 5)), "00abc"));
319
320 %% test/octave.test/string/dec2hex-4.m
321 %!error dec2hex (1, 2, 3);
322
323 %% test/octave.test/string/hex2dec-1.m
324 %!assert(hex2dec ("12b") == 299 && hex2dec ("12B") == 299);
325
326 %% test/octave.test/string/hex2dec-2.m
327 %!error hex2dec ();
328
329 %% test/octave.test/string/hex2dec-3.m
330 %!error hex2dec ("str", 1);
331
332 %% test/octave.test/string/str2num-1.m
333 %!assert(str2num ("-1.3e2") == -130 && str2num ("[1, 2; 3, 4]") == [1, 2; 3, 4]);
334
335 %% test/octave.test/string/str2num-2.m
336 %!error str2num ();
337
338 %% test/octave.test/string/str2num-3.m
339 %!error str2num ("string", 1);
340
341 %% test/octave.test/string/undo_string_escapes-1.m
342 %!assert(strcmp (undo_string_escapes ("abc\a\b\n\r\t\v\f123"),
343 %! "abc\\a\\b\\n\\r\\t\\v\\f123"));
344
345 %% test/octave.test/string/undo_string_escapes-2.m
346 %!error <... undo_string_escapes:.*> undo_string_escapes ();
347
348 %% test/octave.test/string/undo_string_escapes-3.m
349 %!error <... undo_string_escapes:.*> undo_string_escapes ("string", 2);
350
351 %% test/octave.test/string/toascii-1.m
352 %!test
353 %! charset = setstr (0:127);
354 %!
355 %! result = 0:127;
356 %!
357 %! assert(all (toascii (charset) == result));
358
359 %% test/octave.test/string/toascii-3.m
360 %!error toascii (1, 2);
361
362 %% test/octave.test/string/toascii-3.m
363 %!error toascii (1, 2);
364
365 %% test/octave.test/string/tolower-1.m
366 %!test
367 %! charset = setstr (0:127);
368 %!
369 %! result = charset;
370 %!
371 %! result ((toascii("A"):toascii("Z"))+1) \
372 %! = result ((toascii("a"):toascii("z"))+1);
373 %!
374 %! assert(all (tolower (charset) == result));
375
376 %% test/octave.test/string/tolower-3.m
377 %!error tolower (1, 2);
378
379 %% test/octave.test/string/tolower-3.m
380 %!error tolower (1, 2);
381
382 %% test/octave.test/string/toupper-1.m
383 %!test
384 %! charset = setstr (0:127);
385 %!
386 %! result = charset;
387 %!
388 %! result ((toascii("a"):toascii("z"))+1) \
389 %! = result ((toascii("A"):toascii("Z"))+1);
390 %!
391 %! assert(all (toupper (charset) == result));
392
393 %% test/octave.test/string/toupper-3.m
394 %!error toupper (1, 2);
395
396 %% test/octave.test/string/toupper-3.m
397 %!error toupper (1, 2);
398
399 %% test/octave.test/string/isalnum-1.m
400 %!test
401 %! charset = setstr (0:127);
402 %!
403 %! result = zeros (1, 128);
404 %!
405 %! result ((toascii("A"):toascii("Z"))+1) = 1;
406 %! result ((toascii("0"):toascii("9"))+1) = 1;
407 %! result ((toascii("a"):toascii("z"))+1) = 1;
408 %!
409 %! assert(all (isalnum (charset) == result));
410
411 %% test/octave.test/string/isalnum-2.m
412 %!error isalnum (1, 2);
413
414 %% test/octave.test/string/isalnum-3.m
415 %!error isalnum ();
416
417 %% test/octave.test/string/isalpha-1.m
418 %!test
419 %! charset = setstr (0:127);
420 %!
421 %! result = zeros (1, 128);
422 %!
423 %! result ((toascii("A"):toascii("Z"))+1) = 1;
424 %! result ((toascii("a"):toascii("z"))+1) = 1;
425 %!
426 %! assert(all (isalpha (charset) == result));
427
428 %% test/octave.test/string/isalpha-2.m
429 %!error isalpha (1, 2);
430
431 %% test/octave.test/string/isalpha-3.m
432 %!error isalpha ();
433
434 %% test/octave.test/string/isascii-1.m
435 %!test
436 %! charset = setstr (0:127);
437 %!
438 %! result = ones (1, 128);
439 %!
440 %! assert(all (isascii (charset) == result));
441
442 %% test/octave.test/string/isascii-2.m
443 %!error isascii (1, 2);
444
445 %% test/octave.test/string/isascii-3.m
446 %!error isascii ();
447
448 %% test/octave.test/string/iscntrl-1.m
449 %!test
450 %! charset = setstr (0:127);
451 %!
452 %! result = zeros (1, 128);
453 %!
454 %! result (1:32) = 1;
455 %! result (128) = 1;
456 %!
457 %! assert(all (iscntrl (charset) == result));
458
459 %% test/octave.test/string/iscntrl-2.m
460 %!error iscntrl (1, 2);
461
462 %% test/octave.test/string/iscntrl-3.m
463 %!error iscntrl ();
464
465 %% test/octave.test/string/isdigit-1.m
466 %!test
467 %! charset = setstr (0:127);
468 %!
469 %! result = zeros (1, 128);
470 %!
471 %! result ((toascii("0"):toascii("9"))+1) = 1;
472 %!
473 %! assert(all (isdigit (charset) == result));
474
475 %% test/octave.test/string/isdigit-2.m
476 %!error isdigit (1, 2);
477
478 %% test/octave.test/string/isdigit-3.m
479 %!error isdigit ();
480
481 %% test/octave.test/string/isgraph-1.m
482 %!test
483 %! charset = setstr (0:127);
484 %!
485 %! result = zeros (1, 128);
486 %!
487 %! result (34:127) = 1;
488 %!
489 %! assert(all (isgraph (charset) == result));
490
491 %% test/octave.test/string/isgraph-2.m
492 %!error isgraph (1, 2);
493
494 %% test/octave.test/string/isgraph-3.m
495 %!error isgraph ();
496
497 %% test/octave.test/string/islower-1.m
498 %!test
499 %! charset = setstr (0:127);
500 %!
501 %! result = zeros (1, 128);
502 %!
503 %! result ((toascii("a"):toascii("z"))+1) = 1;
504 %!
505 %! assert(all (islower (charset) == result));
506
507 %% test/octave.test/string/islower-2.m
508 %!error islower (1, 2);
509
510 %% test/octave.test/string/islower-3.m
511 %!error islower ();
512
513 %% test/octave.test/string/isprint-1.m
514 %!test
515 %! charset = setstr (0:127);
516 %!
517 %! result = zeros (1, 128);
518 %!
519 %! result (33:127) = 1;
520 %!
521 %! assert(all (isprint (charset) == result));
522
523 %% test/octave.test/string/isprint-2.m
524 %!error isprint (1, 2);
525
526 %% test/octave.test/string/isprint-3.m
527 %!error isprint ();
528
529 %% test/octave.test/string/ispunct-1.m
530 %!test
531 %! charset = setstr (0:127);
532 %!
533 %! result = zeros (1, 128);
534 %!
535 %! result (34:48) = 1;
536 %! result (59:65) = 1;
537 %! result (92:97) = 1;
538 %! result (124:127) = 1;
539 %!
540 %! assert(all (ispunct (charset) == result));
541
542 %% test/octave.test/string/ispunct-2.m
543 %!error ispunct (1, 2);
544
545 %% test/octave.test/string/ispunct-3.m
546 %!error ispunct ();
547
548 %% test/octave.test/string/isspace-1.m
549 %!test
550 %! charset = setstr (0:127);
551 %!
552 %! result = zeros (1, 128);
553 %!
554 %! result (toascii (" \f\n\r\t\v")+1) = 1;
555 %!
556 %! assert(all (isspace (charset) == result));
557
558 %% test/octave.test/string/isspace-2.m
559 %!error isspace (1, 2);
560
561 %% test/octave.test/string/isspace-3.m
562 %!error isspace ();
563
564 %% test/octave.test/string/isupper-1.m
565 %!test
566 %! charset = setstr (0:127);
567 %!
568 %! result = zeros (1, 128);
569 %!
570 %! result ((toascii("A"):toascii("Z"))+1) = 1;
571 %!
572 %! assert(all (isupper (charset) == result));
573
574 %% test/octave.test/string/isupper-2.m
575 %!error isupper (1, 2);
576
577 %% test/octave.test/string/isupper-3.m
578 %!error isupper ();
579
580 %% test/octave.test/string/isxdigit-1.m
581 %!test
582 %! charset = setstr (0:127);
583 %!
584 %! result = zeros (1, 128);
585 %!
586 %! result ((toascii("A"):toascii("F"))+1) = 1;
587 %! result ((toascii("0"):toascii("9"))+1) = 1;
588 %! result ((toascii("a"):toascii("f"))+1) = 1;
589 %!
590 %! assert(all (isxdigit (charset) == result));
591
592 %% test/octave.test/string/isxdigit-2.m
593 %!error isxdigit (1, 2);
594
595 %% test/octave.test/string/isxdigit-3.m
596 %!error isxdigit ();
597