# HG changeset patch # User Carlo de Falco # Date 1387723434 -3600 # Sun Dec 22 15:43:54 2013 +0100 # Branch stable # Node ID 6cf6285aada858c8ee5ffe762a0d31978b4560c1 # Parent fd571d2a18d803ef9652619a7ff0fc3fc4f70af3 Save files to P_tmpdir in tests * test/io.tst: save temporary files to P_tmpdir. diff --git a/test/io.tst b/test/io.tst --- a/test/io.tst +++ b/test/io.tst @@ -74,14 +74,15 @@ %! %! ret = 0; %! -%! files = {"text.mat", "binary.mat", "mat5.mat", "mat7.mat"}; +%! files = cellfun(@fullfile, {P_tmpdir}, {"text.mat", "binary.mat", "mat5.mat", "mat7.mat"}, +%! "UniformOutput", false); %! opts = {"-z -text", "-z -binary", "-z -mat", "-v7"}; %! tols = {2*eps, 0, 0, 0}; %! %! vars = "a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20"; %! if (! input) %! for i = 1:length (files) -%! eval (sprintf ("save %s %s %s", opts{i}, files{i}, vars)); +%! eval (sprintf ("save %s %s %s", files{i}, opts{i}, vars)); %! endfor %! else %! b1 = a1; b2 = a2; b3 = a3; b4 = a4; b5 = a5; @@ -197,8 +198,8 @@ %! STR.struct_fld.x = 0; %! STR.struct_fld.y = 1; %! -%! save struct.dat -struct STR; -%! STR = load ("struct.dat"); +%! save (fullfile (P_tmpdir, "struct.dat"), "-struct", "STR"); +%! STR = load (fullfile (P_tmpdir, "struct.dat")); %! %! assert (STR.scalar_fld == 1 && ... %! STR.matrix_fld == [1.1,2;3,4] && ... @@ -207,8 +208,9 @@ %! STR.struct_fld.y == 1 ); %! %! -%! save -binary struct.dat -struct STR matrix_fld str*_fld; -%! STR = load ("struct.dat"); +%! save ("-binary", fullfile (P_tmpdir, "struct.dat"), +%! "-struct", "STR", "matrix_fld", "str*_fld"); +%! STR = load (fullfile (P_tmpdir, "struct.dat")); %! %! assert (!isfield (STR,"scalar_fld") && ... %! STR.matrix_fld == [1.1,2;3,4] && ... @@ -216,15 +218,15 @@ %! STR.struct_fld.x == 0 && ... %! STR.struct_fld.y == 1); %! -%! delete struct.dat; +%! delete (fullfile (P_tmpdir, "struct.dat")); %!test %! matrix1 = rand (100, 2); -%! save -ascii matrix.ascii matrix1 -%! matrix2 = load ("matrix.ascii"); +%! save ("-ascii", fullfile (P_tmpdir, "matrix.ascii"), "matrix1") +%! matrix2 = load (fullfile (P_tmpdir, "matrix.ascii")); %! assert (matrix1, matrix2, 1e-9); %! -%! delete matrix.ascii; +%! delete (fullfile (P_tmpdir, "matrix.ascii")); %!error load ("")