diff --git a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java index b7d34457d..2a9a83e0b 100644 --- a/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java @@ -638,6 +638,22 @@ public class FileUtilsTest { assertFalse(FILE_UTILS.isLeadingPath(new File("/foo"), new File("/bar"), true)); } + @Test + public void isLeadingPathAndTrailingSlashesOnUnix() throws IOException { + assumeFalse("Test doesn't run on DOS", Os.isFamily("dos")); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo/"), new File("/foo/bar"), true)); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo/"), new File("/foo/bar/"), true)); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo/"), new File("/foo/"), true)); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo/"), new File("/foo"), true)); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo"), new File("/foo/"), true)); + + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo/"), new File("/foo/bar"), false)); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo/"), new File("/foo/bar/"), false)); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo/"), new File("/foo/"), false)); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo/"), new File("/foo"), false)); + assertTrue(FILE_UTILS.isLeadingPath(new File("/foo"), new File("/foo/"), false)); + } + @Test public void isLeadingPathCanonicalVersionWorksAsExpectedOnDos() throws IOException { assumeTrue("Test only runs on DOS", Os.isFamily("dos")); @@ -648,6 +664,22 @@ public class FileUtilsTest { assertFalse(FILE_UTILS.isLeadingPath(new File("C:\\foo"), new File("C:\\bar"), true)); } + @Test + public void isLeadingPathAndTrailingSlashesOnDos() throws IOException { + assumeTrue("Test only runs on DOS", Os.isFamily("dos")); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo\\"), new File("c:\\foo\\bar"), true)); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo\\"), new File("c:\\foo\\bar\\"), true)); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo\\"), new File("c:\\foo\\"), true)); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo\\"), new File("c:\\foo"), true)); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo"), new File("c:\\foo\\"), true)); + + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo\\"), new File("c:\\foo\\bar"), false)); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo\\"), new File("c:\\foo\\bar\\"), false)); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo\\"), new File("c:\\foo\\"), false)); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo\\"), new File("c:\\foo"), false)); + assertTrue(FILE_UTILS.isLeadingPath(new File("c:\\foo"), new File("c:\\foo\\"), false)); + } + /** * adapt file separators to local conventions */