Fix root path test and add more test cases

This commit is contained in:
Rossen Stoyanchev
2017-06-15 16:14:12 -04:00
parent 67e482aaf8
commit 4a21fb27fc
3 changed files with 10 additions and 3 deletions

View File

@@ -190,13 +190,13 @@ class DefaultPathSegmentContainer implements PathSegmentContainer {
}
static PathSegmentContainer subPath(PathSegmentContainer container, int fromIndex, int toIndex) {
if (fromIndex == toIndex) {
return EMPTY_PATH;
}
List<PathSegment> segments = container.pathSegments();
if (fromIndex == 0 && toIndex == segments.size()) {
return container;
}
if (fromIndex == toIndex) {
return EMPTY_PATH;
}
Assert.isTrue(fromIndex < toIndex, "fromIndex: " + fromIndex + " should be < toIndex " + toIndex);
Assert.isTrue(fromIndex >= 0 && fromIndex < segments.size(), "Invalid fromIndex: " + fromIndex);