Mercurial > octave
comparison test/io.tst @ 31172:e8a46f801825 stable
io.tst: Add test case for scanf (bug #62723).
* test/io.tst: Add test case for sscanf that reaches the end of stream with
a pattern that matches characters.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Wed, 03 Aug 2022 19:00:08 +0200 |
parents | 796f54d4ddbf |
children | 6bd338605fd3 332a6ccac881 |
comparison
equal
deleted
inserted
replaced
31170:bcd75c07c9e8 | 31172:e8a46f801825 |
---|---|
384 %! [val, count, msg, pos] = sscanf ("3Inf2", "%f"); | 384 %! [val, count, msg, pos] = sscanf ("3Inf2", "%f"); |
385 %! assert (val, [3; Inf; 2]); | 385 %! assert (val, [3; Inf; 2]); |
386 %! assert (count, 3); | 386 %! assert (count, 3); |
387 %! assert (msg, ""); | 387 %! assert (msg, ""); |
388 %! assert (pos, 6); | 388 %! assert (pos, 6); |
389 | |
390 %!test <*62723> | |
391 %! [val, count, msg, pos] = sscanf ("p", "%c"); | |
392 %! assert (val, "p"); | |
393 %! assert (count, 1); | |
394 %! assert (msg, ""); | |
395 %! assert (pos, 2); | |
389 | 396 |
390 %!test | 397 %!test |
391 %! [a, b, c] = sscanf ("1.2 3 foo", "%f%d%s", "C"); | 398 %! [a, b, c] = sscanf ("1.2 3 foo", "%f%d%s", "C"); |
392 %! [v1, c1, m1] = sscanf ("1 2 3 4 5 6", "%d"); | 399 %! [v1, c1, m1] = sscanf ("1 2 3 4 5 6", "%d"); |
393 %! [v2, c2, m2] = sscanf ("1 2 bar 3 4 5 6", "%d"); | 400 %! [v2, c2, m2] = sscanf ("1 2 bar 3 4 5 6", "%d"); |