Mercurial > hg > octave-nkf
diff test/io.tst @ 18209:a0abcf377ec5 stable
return elements read, not bytes in fread second output (bug #41091)
* oct-stream.cc (octave_stream::read): Rename char_count arg to be
count. Make char_count a local variable. Use count instead of
elts_read. Correctly truncate size of result matrix if fewer elements
are read than requested.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 03 Jan 2014 17:29:08 -0500 |
parents | d63878346099 |
children | 77fa327a956d fdd27f68b011 |
line wrap: on
line diff
--- a/test/io.tst +++ b/test/io.tst @@ -527,3 +527,23 @@ %!error <Invalid call to frewind> frewind (1, 2) %!error frewind ("foo") +%!test +%! id = tmpfile (); +%! fwrite (id, "abcdefg"); +%! frewind (id); +%! [data, count] = fread (id); +%! assert (data, [97; 98; 99; 100; 101; 102; 103]); +%! assert (count, 7); +%! frewind (id); +%! [data, count] = fread (id, 'int16'); +%! assert (data, [25185; 25699; 26213]); +%! assert (count, 3); +%! frewind (id); +%! [data, count] = fread (id, [10, 2], 'int16'); +%! assert (data, [25185; 25699; 26213]); +%! assert (count, 3); +%! frewind (id); +%! [data, count] = fread (id, [2, 10], 'int16'); +%! assert (data, [25185, 26213; 25699, 0]); +%! assert (count, 3); +%! fclose (id);