Mercurial > octave
comparison test/io.tst @ 28221:ebff357efd56
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 14 Apr 2020 22:55:33 -0400 |
parents | 501553fcf6e2 6cccc3c82175 |
children | 822dc79a7e97 |
comparison
equal
deleted
inserted
replaced
28218:8619dc0d3749 | 28221:ebff357efd56 |
---|---|
920 %!assert (sprintf ("a %s b", ''), "a b") | 920 %!assert (sprintf ("a %s b", ''), "a b") |
921 %!assert (sprintf ("a %s b", ' '), "a b") | 921 %!assert (sprintf ("a %s b", ' '), "a b") |
922 | 922 |
923 %!assert <*53148> (double (sprintf ("B\0B")), [66, 0, 66]) | 923 %!assert <*53148> (double (sprintf ("B\0B")), [66, 0, 66]) |
924 %!assert <*53148> (sscanf ("B\0B 13", "B\0B %d"), 13) | 924 %!assert <*53148> (sscanf ("B\0B 13", "B\0B %d"), 13) |
925 | |
926 %!test <58055> | |
927 %! w_modes = {"wb", "wt"}; | |
928 %! r_modes = {"rb", "rt"}; | |
929 %! f_texts = {"foo\nbar\nbaz\n", "foo\rbar\rbaz\r", "foo\r\nbar\r\nbaz\r\n"}; | |
930 %! for i = 1:numel (w_modes) | |
931 %! w_mode = w_modes{i}; | |
932 %! for j = 1:numel (r_modes); | |
933 %! r_mode = r_modes{j}; | |
934 %! for k = 1:numel (f_texts); | |
935 %! f_text = f_texts{k}; | |
936 %! fname = tempname () | |
937 %! fid = fopen (fname, w_mode); | |
938 %! unwind_protect | |
939 %! fprintf (fid, "%s", f_text); | |
940 %! fclose (fid); | |
941 %! fid = fopen (fname, r_mode) | |
942 %! fgetl (fid); | |
943 %! pos = ftell (fid); | |
944 %! buf1 = fgetl (fid); | |
945 %! fgetl (fid); | |
946 %! fseek (fid, pos, SEEK_SET); | |
947 %! buf2 = fgetl (fid); | |
948 %! assert (buf1, buf2); | |
949 %! unwind_protect_cleanup | |
950 %! fclose (fid); | |
951 %! unlink (fname); | |
952 %! end_unwind_protect | |
953 %! endfor | |
954 %! endfor | |
955 %! endfor |