Mercurial > hg > octave-terminal
changeset 13767:2b98014771b4
fileread.m: Add functional test.
* fileread.m: Add functional test.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 27 Oct 2011 22:17:03 -0700 |
parents | 453997717598 |
children | 5f96b91b4e0c |
files | scripts/io/fileread.m |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/io/fileread.m +++ b/scripts/io/fileread.m @@ -29,7 +29,7 @@ endif if (! ischar (filename)) - error ("fileread: argument must be a string"); + error ("fileread: FILENAME argument must be a string"); endif fid = fopen (filename, "r"); @@ -45,3 +45,19 @@ endfunction + +%!test +%! cstr = {"Hello World", "The answer is 42", "Goodbye World"}; +%! fname = tmpnam (); +%! fid = fopen (fname, "wt"); +%! fprintf(fid, "%s\n", cstr{:}) +%! fclose (fid); +%! str = fileread (fname); +%! assert (str', [cstr{1} "\n" cstr{2} "\n" cstr{3} "\n"]); +%! unlink (fname); + +%% Test input validation +%!error fileread () +%!error fileread (1, 2) +%!error <FILENAME argument must be a string> fileread (1) +