diff test/io.tst @ 18512:fdd27f68b011 stable

handle fread skip parameter correctly (bug #41648) * oct-stream.cc (octave_stream::read): Decide whether to skip based on current number of elements read, not total. Correctly handle case of reading partial blocks when there is a repeat cound. Skip to EOF if the full skip is beyond EOF. * io.tst: New test.
author Rik <rik@octave.org> and John W. Eaton <jwe@octave.org>
date Fri, 21 Feb 2014 15:28:02 -0500
parents a0abcf377ec5
children 39fbe4aba560 0bdecd41b2dd
line wrap: on
line diff
--- a/test/io.tst	Thu Jan 16 16:26:56 2014 -0500
+++ b/test/io.tst	Fri Feb 21 15:28:02 2014 -0500
@@ -547,3 +547,25 @@
 %! assert (data, [25185, 26213; 25699, 0]);
 %! assert (count, 3);
 %! fclose (id);
+
+%!test
+%! id = tmpfile ();
+%! fwrite (id, char (0:15));
+%! frewind (id);
+%! [data, count] = fread (id, inf, "2*uint8", 2);
+%! assert (data, [0; 1; 4; 5; 8; 9; 12; 13]);
+%! assert (count, 8);
+%! frewind (id);
+%! [data, count] = fread (id, 3, "2*uint8", 3);
+%! assert (data, [0; 1; 5]);
+%! assert (count, 3);
+%! [data, count] = fread (id, 3, "2*uint8", 3);
+%! assert (data, [6; 7; 11]);
+%! assert (count, 3);
+%! [data, count] = fread (id, 3, "2*uint8", 3);
+%! assert (data, [12; 13]);
+%! assert (count, 2);
+%! [data, count] = fread (id, 3, "2*uint8", 3);
+%! assert (data, []);
+%! assert (count, 0);
+%! fclose (id);