diff test/test_io.m @ 7635:ba7a3e20ee3d

add -struct modifier to save
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 25 Mar 2008 15:29:26 -0400
parents 3422f39573b1
children a2d9f325b65a
line wrap: on
line diff
--- a/test/test_io.m
+++ b/test/test_io.m
@@ -186,6 +186,36 @@
 %! endfor
 %! 
 %! assert(save_status && load_status);
+%!
+%!test
+%! 
+%! STR.scalar_fld = 1;
+%! STR.matrix_fld = [1.1,2;3,4];
+%! STR.string_fld = "Octave";
+%! STR.struct_fld.x = 0;
+%! STR.struct_fld.y = 1;
+%! 
+%! save struct.dat -struct STR;
+%! STR = load struct.dat ;
+%!
+%! assert(STR.scalar_fld == 1 && ...
+%! 	STR.matrix_fld == [1.1,2;3,4] && ...
+%! 	STR.string_fld == "Octave" && ...
+%! 	STR.struct_fld.x == 0 && ...
+%! 	STR.struct_fld.y == 1 );
+%!
+%!
+%! save -binary struct.dat -struct STR matrix_fld str*_fld;
+%! STR = load struct.dat ;
+%!
+%! assert(!isfield(STR,"scalar_fld") && ...
+%! 	STR.matrix_fld == [1.1,2;3,4] && ...
+%! 	STR.string_fld == "Octave" && ...
+%! 	STR.struct_fld.x == 0 && ...
+%! 	STR.struct_fld.y == 1);
+%!
+%! delete struct.dat;
+%!
 
 %% FIXME Disable this test as it writes to stdout and there is no easy
 %% way to recover output. Need to spawn new octave process and pipe stdout