Mercurial > hg > octave-lyh
changeset 16974:221e71d2aef0
Unlink tmp files in %!tests before doing asserts so that file is always removed.
* scripts/audio/wavwrite.m, scripts/io/csvwrite.m, scripts/io/fileread.m:
Unlink tmp files in %!tests before doing asserts so that file is always removed
even if test fails on assert.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 13 Jul 2013 10:46:43 -0700 |
parents | d429a05dc11c |
children | 47cc8e3d9183 |
files | scripts/audio/wavwrite.m scripts/io/csvwrite.m scripts/io/fileread.m |
diffstat | 3 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/audio/wavwrite.m +++ b/scripts/audio/wavwrite.m @@ -157,43 +157,43 @@ %! A = [-1:0.1:1; -1:0.1:1]; %! wavwrite (A, fname); %! [B, samples_per_sec, bits_per_sample] = wavread (fname); +%! unlink (fname); %! assert (A,B, 1/2^15); %! assert (samples_per_sec, 8000); %! assert (bits_per_sample, 16); -%! unlink (fname); -% + %!test %! A = [-1:0.1:1; -1:0.1:1]; %! wavwrite (A, 4000, fname); %! [B, samples_per_sec, bits_per_sample] = wavread (fname); +%! unlink (fname); %! assert (A,B, 1/2^15); %! assert (samples_per_sec, 4000); %! assert (bits_per_sample, 16); -%! unlink (fname); -% + %!test %! A = [-1:0.1:1; -1:0.1:1]; %! wavwrite (A, 4000, 8, fname); %! [B, samples_per_sec, bits_per_sample] = wavread (fname); +%! unlink (fname); %! assert (A,B, 1/128); %! assert (samples_per_sec, 4000); %! assert (bits_per_sample, 8); -%! unlink (fname); -% + %!test %! A = [-2:2]'; %! wavwrite (A, fname); %! B = wavread (fname); +%! unlink (fname); %! B *= 32768; %! assert (B, [-32768 -32768 0 32767 32767]'); -%! unlink (fname); -% + %!test %! A = [-1:0.1:1]; %! wavwrite (A, fname); %! [B, samples_per_sec, bits_per_sample] = wavread (fname); +%! unlink (fname); %! assert (A', B, 1/2^15); %! assert (samples_per_sec, 8000); %! assert (bits_per_sample, 16); -%! unlink (fname);
--- a/scripts/io/csvwrite.m +++ b/scripts/io/csvwrite.m @@ -41,14 +41,15 @@ %!test %! csvwrite (fname, magic (3)); -%! assert (csvread (fname), magic (3)); +%! data = csvread (fname); %! unlink (fname); +%! assert (data, magic (3)); %!test %! csvwrite (fname, magic (3), "precision", "%2.1f", "newline", "unix"); %! fid = fopen (fname, "rt"); %! txt = char (fread (fid,Inf,'char')'); %! fclose (fid); +%! unlink (fname); %! assert (txt, "8.0,1.0,6.0\n3.0,5.0,7.0\n4.0,9.0,2.0\n"); -%! unlink (fname);