changeset 23093:8aba6d170887

fix prototype of octave_base_int<T>::write (bug #50157) * ov-intx.h (octave_base_int_scalar::write): Fix declaration. The skip parameter is int, not octave_idx_type. * test/io.tst: New test.
author John W. Eaton <jwe@octave.org>
date Thu, 26 Jan 2017 12:19:15 -0500
parents 0fed4c678795
children 28c9a42cfbf8
files libinterp/octave-value/ov-intx.h test/io.tst
diffstat 2 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-intx.h	Thu Jan 26 08:26:46 2017 -0500
+++ b/libinterp/octave-value/ov-intx.h	Thu Jan 26 12:19:15 2017 -0500
@@ -612,7 +612,7 @@
   idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (scalar); }
 
   int write (octave::stream& os, int block_size,
-             oct_data_conv::data_type output_type, octave_idx_type skip,
+             oct_data_conv::data_type output_type, int skip,
              octave::mach_info::float_format flt_fmt) const
   {
     return os.write (OCTAVE_VALUE_INT_NDARRAY_EXTRACTOR_FUNCTION (),
--- a/test/io.tst	Thu Jan 26 08:26:46 2017 -0500
+++ b/test/io.tst	Thu Jan 26 12:19:15 2017 -0500
@@ -496,6 +496,30 @@
 %! assert (__prog_output_assert__ ("ok"));
 
 %!test
+%! classes = {"int8", "int16", "int32", "int64", ...
+%!            "uint8", "uint16", "uint32", "uint64", ...
+%!            "single", "double"};
+%! nm = tempname ();
+%! id = fopen (nm, "wb+");
+%! n = numel (classes);
+%! for i = 1:n
+%!   cls = classes{i};
+%!   s_in = ones (1, 1, cls);
+%!   m_in = ones (2, 2, cls);
+%!   m_shape = size (m);
+%!   fwrite (id, s, numel (s), cls);
+%!   fwrite (id, m, numel (m), cls);
+%!   frewind (id);
+%!   s_out = fread (id, numel (s_in), sprintf ("%s=>%s", cls, cls));
+%!   m_out = fread (id, numel (m_in), sprintf ("%s=>%s", cls, cls));
+%!   m_out = reshape (m_out, m_shape);
+%!   fclose (id);
+%!   unlink (nm);
+%!   assert (s_in, s_out);
+%!   assert (m_in, m_out);
+%! endfor
+
+%!test
 %! x = char (128:255)';
 %! nm = tempname ();
 %! id = fopen (nm, "wb");