diff test/test_io.m @ 12995:7872afb42fab

fix scanf problem with reading I (bug #33722) * lo-utils.cc (read_inf_nan_na, read_float_inf_nan_na): Return characters to input stream and set stream state on failed reads. (read_float_inf_nan_na): Use Float versions of Inf, NaN, and NA * test_io.m: New tests.
author John W. Eaton <jwe@octave.org>
date Wed, 24 Aug 2011 12:13:11 -0400
parents 7626f8934466
children 38b52a073cfa
line wrap: on
line diff
--- a/test/test_io.m
+++ b/test/test_io.m
@@ -245,6 +245,27 @@
 %!assert (sscanf ('123456', '%10c'), '123456')
 %!assert (sscanf ('123456', '%10s'), '123456')
 
+%!test
+%! [val, count, msg, pos] = sscanf ("3I2", "%f")
+%! assert (val, 3);
+%! assert (count, 1);
+%! assert (msg, "");
+%! assert (pos, 2);
+
+%!test
+%! [val, count, msg, pos] = sscanf ("3In2", "%f")
+%! assert (val, 3);
+%! assert (count, 1);
+%! assert (msg, "");
+%! assert (pos, 2);
+
+%!test
+%! [val, count, msg, pos] = sscanf ("3Inf2", "%f")
+%! assert (val, [3; Inf, 2);
+%! assert (count, 3);
+%! assert (msg, "");
+%! assert (pos, 6);
+
 %% test/octave.test/io/sscanf-1.m
 %!test
 %! [a, b, c] = sscanf ("1.2 3 foo", "%f%d%s", "C");