Mercurial > hg > octave-terminal
changeset 11931:d7d30988b3ea release-3-0-x
fix fileparts tests
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 29 Jan 2009 08:48:30 +0100 |
parents | 5032328e940b |
children | 8d1427a14f45 |
files | scripts/ChangeLog scripts/miscellaneous/fileparts.m |
diffstat | 2 files changed, 16 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2009-01-29 Jaroslav Hajek <highegg@gmail.com> + + * miscellaneous/fileparts.m: Fix test for Windows. + 2009-01-16 Daniel J Sebald <daniel.sebald@ieee.org> * plot/legend.m: Fix legend order for both horizontal and
--- a/scripts/miscellaneous/fileparts.m +++ b/scripts/miscellaneous/fileparts.m @@ -27,7 +27,11 @@ if (nargin == 1) if (ischar (filename)) - ds = rindex (filename, filesep); + if !( findstr (octave_config_info('canonical_host_type'), 'msvc') || findstr (octave_config_info('canonical_host_type'), 'mingw') ) + ds = rindex (filename, filesep); + else + ds = max (rindex (filename, "\\"),rindex (filename, "/")); + endif es = rindex (filename, "."); ## These can be the same if they are both 0 (no dir or ext). if (es <= ds) @@ -65,27 +69,27 @@ %! assert (strcmp (d, "") && strcmp (n, "file") && strcmp (e, ".ext")); %!test -%! [d, n, e] = fileparts ("/file.ext"); -%! assert (strcmp (d, "/") && strcmp (n, "file") && strcmp (e, ".ext")); +%! [d, n, e] = fileparts ([filesep "file.ext"]); +%! assert (strcmp (d, filesep) && strcmp (n, "file") && strcmp (e, ".ext")); %!test -%! [d, n, e] = fileparts ("dir/file.ext"); +%! [d, n, e] = fileparts (["dir" filesep "file.ext"]); %! assert (strcmp (d, "dir") && strcmp (n, "file") && strcmp (e, ".ext")); %!test -%! [d, n, e] = fileparts ("./file.ext"); +%! [d, n, e] = fileparts (["." filesep "file.ext"); %! assert (strcmp (d, ".") && strcmp (n, "file") && strcmp (e, ".ext")); %!test -%! [d, n, e] = fileparts ("d1/d2/file.ext"); +%! [d, n, e] = fileparts (["d1" filesep "d2" filesep "file.ext"]); %! assert (strcmp (d, "d1/d2") && strcmp (n, "file") && strcmp (e, ".ext")); %!test -%! [d, n, e] = fileparts ("/d1/d2/file.ext"); +%! [d, n, e] = fileparts ([filesep "d1" filesep "d2" filesep "file.ext"]); %! assert (strcmp (d, "/d1/d2") && strcmp (n, "file") && strcmp (e, ".ext")); %!test -%! [d, n, e] = fileparts ("/.ext"); +%! [d, n, e] = fileparts ([filesep ".ext"]); %! assert (strcmp (d, "/") && strcmp (n, char (zeros (1, 0))) && strcmp (e, ".ext")); %!test