local history: index out of bounds fixed

This commit is contained in:
Anton Makeev
2010-12-15 16:44:53 +03:00
parent b7df56a842
commit 91adad757f
2 changed files with 5 additions and 1 deletions
@@ -44,7 +44,6 @@ public class Paths {
}
public static String appended(String path, String child) {
if (path.length() == 0) return child;
path = appendParent(path);
return path + child;
}
@@ -82,6 +81,7 @@ public class Paths {
}
private static String appendParent(String parent) {
if (parent.isEmpty()) return parent;
if (parent.charAt(parent.length() - 1) != DELIM) parent += DELIM;
return parent;
}
@@ -42,6 +42,8 @@ public class PathsTest extends LocalHistoryTestCase {
assertEquals("c:/root/file", Paths.appended("c:/root", "file"));
assertEquals("/foo", Paths.appended("/", "foo"));
assertEquals("/foo/bar", Paths.appended("/foo", "bar"));
assertEquals("bar", Paths.appended("", "bar"));
}
@Test
@@ -79,6 +81,8 @@ public class PathsTest extends LocalHistoryTestCase {
assertFalse(Paths.isParent("foo/bar", "foo/baz"));
assertFalse(Paths.isParent("foo/bar", "foo/barr"));
assertFalse(Paths.isParent("foo/bar", "foo/barr/baz"));
assertTrue(Paths.isParent("", "foo"));
}
@Test