diff scripts/io/textscan.m @ 12891:f5a3f77d51aa

strread.m, textscan.m: More Matlab compatability * strread.m, textscan.m: Add support for "MultipleDelimsAsOne" option. Correctly handle comment end character when "EndOfLine" option used. Add more tests.
author Philip Nienhuis <prnienhuis@users.sf.net>
date Tue, 26 Jul 2011 22:24:32 -0700
parents ff264eae88cf
children ac00ae83ea2e
line wrap: on
line diff
--- a/scripts/io/textscan.m
+++ b/scripts/io/textscan.m
@@ -241,6 +241,16 @@
 %! assert (a{2}', {'B' 'J' 'R' 'Z'});
 %! assert (a{3}', [16 241 3 NaN], 1e-5);
 
+%% Test with default endofline parameter
+%!test
+%! c = textscan ("L1\nL2", "%s");
+%! assert (c{:}, {"L1"; "L2"});
+
+%% Test with endofline parameter set to '' (empty) - newline should be in word
+%!test
+%! c = textscan ("L1\nL2", "%s", 'endofline', '');
+%! assert (int8(c{:}{:}), int8([ 76,  49,  10,  76,  50 ]));
+
 %% Test input validation
 %!error textscan ()
 %!error textscan (single (4))