comparison test/io.tst @ 18210: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
comparison
equal deleted inserted replaced
18209:1c1236fd179a 18210:a0abcf377ec5
525 525
526 %!error <Invalid call to frewind> frewind () 526 %!error <Invalid call to frewind> frewind ()
527 %!error <Invalid call to frewind> frewind (1, 2) 527 %!error <Invalid call to frewind> frewind (1, 2)
528 %!error frewind ("foo") 528 %!error frewind ("foo")
529 529
530 %!test
531 %! id = tmpfile ();
532 %! fwrite (id, "abcdefg");
533 %! frewind (id);
534 %! [data, count] = fread (id);
535 %! assert (data, [97; 98; 99; 100; 101; 102; 103]);
536 %! assert (count, 7);
537 %! frewind (id);
538 %! [data, count] = fread (id, 'int16');
539 %! assert (data, [25185; 25699; 26213]);
540 %! assert (count, 3);
541 %! frewind (id);
542 %! [data, count] = fread (id, [10, 2], 'int16');
543 %! assert (data, [25185; 25699; 26213]);
544 %! assert (count, 3);
545 %! frewind (id);
546 %! [data, count] = fread (id, [2, 10], 'int16');
547 %! assert (data, [25185, 26213; 25699, 0]);
548 %! assert (count, 3);
549 %! fclose (id);