diff --git a/test/TestFileImpure.m b/test/TestFileImpure.m index 4dc26e7..3dd057d 100644 --- a/test/TestFileImpure.m +++ b/test/TestFileImpure.m @@ -5,16 +5,16 @@ end properties(TestParameter) -in_exists = {pwd, mfilename("fullpath") + ".m", "not-exists"} -ref_exists = {true, true, false} +p_exists = {{pwd, true}, {mfilename("fullpath") + ".m", true}, {tempname, false}} % on CI matlabroot can be writable! in_is_write = {pwd, "not-exists"}; ref_is_write = {true, false} -in_expand = {"", "~abc", "~", "~/foo"} -ref_expand -in_same = {"", tempname, "..", ".."} -other_same = {"", tempname, "./..", fullfile(pwd, "..")} -ref_same = {false, false, true, true} +p_expand +p_same = {... +{"","", false}, ... +{tempname, tempname, false}, ... +{"..", "./..", true}, ... +{"..", pwd + "/..", true}} end properties @@ -24,12 +24,11 @@ methods (TestParameterDefinition, Static) -function ref_expand = init_expand(classToTest) %#ok +function p_expand = init_expand(classToTest) %#ok cwd = fileparts(mfilename("fullpath")); top = fullfile(cwd, ".."); addpath(top) - -ref_expand = {"", "~abc", stdlib.homedir, stdlib.join(stdlib.homedir, "foo")}; +p_expand = {{"", ""}, {"~abc", "~abc"}, {"~", stdlib.homedir}, {"~/foo", stdlib.join(stdlib.homedir, "foo")}}; end end @@ -52,13 +51,13 @@ function setup_path(tc) methods (Test, ParameterCombination = 'sequential') -function test_exists(tc, in_exists, ref_exists) -tc.verifyEqual(stdlib.exists(in_exists), ref_exists) +function test_exists(tc, p_exists) +tc.verifyEqual(stdlib.exists(p_exists{1}), p_exists{2}) end -function test_is_readable(tc, in_exists, ref_exists) -tc.verifyEqual(stdlib.is_readable(in_exists), ref_exists) +function test_is_readable(tc, p_exists) +tc.verifyEqual(stdlib.is_readable(p_exists{1}), p_exists{2}) end @@ -67,8 +66,8 @@ function test_is_writable(tc, in_is_write, ref_is_write) end -function test_expanduser(tc, in_expand, ref_expand) -tc.verifyEqual(stdlib.expanduser(in_expand), ref_expand) +function test_expanduser(tc, p_expand) +tc.verifyEqual(stdlib.expanduser(p_expand{1}), p_expand{2}) end @@ -87,8 +86,8 @@ function test_makedir(tc) end %% -function test_samepath(tc, in_same, other_same, ref_same) -tc.verifyEqual(stdlib.samepath(in_same, other_same), ref_same) +function test_samepath(tc, p_same) +tc.verifyEqual(stdlib.samepath(p_same{1}, p_same{2}), p_same{3}) end diff --git a/test/TestFilePure.m b/test/TestFilePure.m index c64fc37..39cf6e3 100644 --- a/test/TestFilePure.m +++ b/test/TestFilePure.m @@ -5,10 +5,8 @@ end properties (TestParameter) -base_relative_to -other_relative_to -ref_relative_to -ref_proximate_to +p_relative_to +p_proximate_to in_is_absolute ref_is_absolute in_filename = {'', '/foo/bar/baz', '/foo/bar/baz/', 'foo/bar/baz.txt', 'foo/bar/baz.txt.gz'} @@ -20,17 +18,27 @@ in_parent ref_parent -in_join = {"", "a", "", "a/b/", "/", "", "a", "a//", "a/b/../", "a/b", "a/b", "ab/cd"} -other_join = {"", "", "b", "c/", "", "/", "b//", "b//", "c/d/../", "..", "c/d", "/ef"} -ref_join = {"", "a", "b", "a/b/c", "/", "/", "a/b", "a/b", "a/c", "a", "a/b/c/d", "/ef"} +p_join = {{"", "", ""}, ... +{"a", "", "a"}, ... +{"", "a", "a"}, ... +{"a/b/", "c/", "a/b/c"}, ... +{"/", "", "/"}, ... +{"", "/", "/"}, ... +{"a", "b//", "a/b"}, ... +{"a//", "b//", "a/b"}, ... +{"a/b/../", "c/d/../", "a/c"}, ... +{"a/b", "..", "a"}, ... +{"a/b", "c/d", "a/b/c/d"}, ... +{"ab/cd", "/ef", "/ef"} ... +}; in_suffix = {"", "/foo/bar/baz", "/foo/bar/baz/", "foo/bar/baz.txt", "foo/bar/baz.txt.gz", ".stat", ".stat.txt"} ref_suffix = {"", "", "", ".txt", ".gz", ".stat", ".txt"} -in_norm = {"", "//a/b/", "/a/b/", "a/b/", "a/../c", "a/b/../c", "a/b/../../c", "a/b/../../c/..", ... - "a/b/../../c/../..", "a////b"} -ref_norm = {".", "/a/b", "/a/b", "a/b", "c", "a/c", "c", ".", ... - "..", "a/b"} +in_norm = {"", "a/..", "//a/b/", "/a/b/", "a/b/", "a/../c", "a/b/../c", "a/b/../../c", "a/b/../../c/..", ... + "a/b/../../c/../..", "a////b", ".a", "..a", "a.", "a..", "./a/.", "../a"} +ref_norm = {".", ".", "/a/b", "/a/b", "a/b", "c", "a/c", "c", ".", ... + "..", "a/b", ".a", "..a", "a.", "a..", "a", "../a"} in_root ref_root @@ -41,7 +49,7 @@ end methods (TestParameterDefinition, Static) -function [base_relative_to, other_relative_to, ref_relative_to, ref_proximate_to, in_root, ref_root, in_parent, ref_parent] = init_relative_to(classToTest) %#ok +function [p_relative_to, p_proximate_to, in_root, ref_root, in_parent, ref_parent] = init_relative_to(classToTest) %#ok in_root = {"", "a/b", "./a/b", "../a/b", "/etc", "c:/etc"}; ref_root = {"", "", "", "", "/", ""}; @@ -49,18 +57,24 @@ in_parent = {"", ".", "..", "../..", "a/", "a/b", "a/b/", "ab/.parent", "ab/.parent.txt", "a/b/../.parent.txt", "a/////b////c", "c:/", "c:\", "c:/a/b", "c:\a/b"}; ref_parent = {".", ".", ".", "..", ".", "a", "a", "ab", "ab", "a/b/..", "a/b", ".", ".", "c:/a", "c:\a"}; -if ispc - -base_relative_to = {'', 'Hello', 'Hello', ... -'c:\a\b', 'c:\', 'c:/a/b', 'c:/a/b', 'c:\a/b\c/d', 'c:/path'}; +p_relative_to = {{'', '', '.'}, ... +{'Hello', 'Hello', '.'}, ... +{'Hello', 'Hello/', '.'}, ... +{'./this/one', './this/two', '../two'}, ... +{'/path/same', '/path/same/hi/..', '.'}}; -other_relative_to = {'', 'Hello', 'Hello/', ... -'c:/', 'c:/a/b', 'c:/a/b', 'c:/a', 'c:/a\b', 'd:/path'}; +if ispc -ref_relative_to = {'.', '.', '.', '../..', 'a/b', '.', '..', '../..', ''}; +p_relative_to = [p_relative_to, ...{ +{{'c:\a\b', 'c:/', '../..'}, ... +{'c:\', 'c:/a/b', 'a/b'}, ... +{'c:/a/b', 'c:/a/b', '.'}, ... +{'c:/a/b', 'c:/a', '..'}, ... +{'c:\a/b\c/d', 'c:/a\b', '../..'}, ... +{'c:/path', 'd:/path', ''}}]; -ref_proximate_to = ref_relative_to; -ref_proximate_to{end} = other_relative_to{end}; +p_proximate_to = p_relative_to; +p_proximate_to{end}{3} = "d:/path"; ref_parent{12} = "c:/"; ref_parent{13} = "c:/"; @@ -72,27 +86,27 @@ else -base_relative_to = {'', '', '/', '/', 'Hello', 'Hello', '/dev/null', '/a/b', 'c', ... -'/a/b', '/a/b', '/a/b/c/d', '/this/one', '/path/same'}; - -other_relative_to = {'', '/', '', '/', 'Hello', 'Hello/', '/dev/null', 'c', '/a/b', ... -'/a/b', '/a', '/a/b', '/this/two', '/path/same/hi/..'}; - -ref_relative_to = {'.', '', '', '.', '.', '.', '.', '', '', ... -'.', '..', '../..', '../two', '.'}; - -ref_proximate_to = ref_relative_to; -ref_proximate_to{2} = '/'; -ref_proximate_to{8} = 'c'; -ref_proximate_to{9} = '/a/b'; +p_relative_to = [p_relative_to, ... +{{'', '/', ''}, ... +{'/', '', ''}, ... +{'/', '/', '.'}, ... +{'/dev/null', '/dev/null', '.'}, ... +{'/a/b', 'c', ''}, ... +{'c', '/a/b', ''}, ... +{'/a/b', '/a/b', '.'}, ... +{'/a/b', '/a', '..'}, ... +{'/a/b/c/d', '/a/b', '../..'}, ... +{'/this/one', '/this/two', '../two'}, ... +{'/path/same', '/path/same/hi/..', '.'}}]; + + +p_proximate_to = p_relative_to; +p_proximate_to{7}{3} = '/'; +p_proximate_to{13}{3} = 'c'; +p_proximate_to{14}{3} = '/a/b'; end -base_relative_to{end+1} = './this/one'; -other_relative_to{end+1} = './this/two'; -ref_relative_to{end+1} = '../two'; -ref_proximate_to{end+1} = ref_relative_to{end}; - end @@ -170,8 +184,8 @@ function test_posix(tc) end -function test_join(tc, in_join, other_join, ref_join) -tc.verifyEqual(stdlib.join(in_join, other_join), ref_join) +function test_join(tc, p_join) +tc.verifyEqual(stdlib.join(p_join{1}, p_join{2}), p_join{3}) end @@ -236,15 +250,15 @@ function test_with_suffix(tc) end -function test_relative_to(tc, base_relative_to, other_relative_to, ref_relative_to) +function test_relative_to(tc, p_relative_to) tc.assumeTrue(stdlib.has_java) -tc.verifyEqual(stdlib.relative_to(base_relative_to, other_relative_to), string(ref_relative_to)) +tc.verifyEqual(stdlib.relative_to(p_relative_to{1}, p_relative_to{2}), string(p_relative_to{3})) end -function test_proximate_to(tc, base_relative_to, other_relative_to, ref_proximate_to) +function test_proximate_to(tc, p_proximate_to) tc.assumeTrue(stdlib.has_java) -tc.verifyEqual(stdlib.proximate_to(base_relative_to, other_relative_to), string(ref_proximate_to)) +tc.verifyEqual(stdlib.proximate_to(p_proximate_to{1}, p_proximate_to{2}), string(p_proximate_to{3})) end