@Test
public void shouldReturnSubpathIfValidStartingIndexAndEndingIndexAreProvided() {

    path = pathFactory.create("/mode:a/b/mode:c/../d/./mode:e/../..");
    assertThat(path.subpath(0, path.size()),
               hasSegments(pathFactory, "mode:a", "b", "mode:c", "..", "d", ".", "mode:e", "..", ".."));
    assertThat(path.subpath(0, path.size()), is(path));
    assertThat(path.subpath(0, path.size()), is(sameInstance(path)));
    assertThat(path.subpath(1, path.size()), hasSegments(pathFactory, "b", "mode:c", "..", "d", ".", "mode:e", "..", ".."));
    assertThat(path.subpath(2, path.size()), hasSegments(pathFactory, "mode:c", "..", "d", ".", "mode:e", "..", ".."));
    assertThat(path.subpath(3, path.size()), hasSegments(pathFactory, "..", "d", ".", "mode:e", "..", ".."));
    assertThat(path.subpath(4, path.size()), hasSegments(pathFactory, "d", ".", "mode:e", "..", ".."));
    assertThat(path.subpath(5, path.size()), hasSegments(pathFactory, ".", "mode:e", "..", ".."));
    assertThat(path.subpath(6, path.size()), hasSegments(pathFactory, "mode:e", "..", ".."));
    assertThat(path.subpath(7, path.size()), hasSegments(pathFactory, "..", ".."));
    assertThat(path.subpath(8, path.size()), hasSegments(pathFactory, ".."));
    assertThat(path.subpath(0, 2), hasSegments(pathFactory, "mode:a", "b"));
    assertThat(path.subpath(1, 2), hasSegments(pathFactory, "b"));
    assertThat(path.subpath(1, 5), hasSegments(pathFactory, "b", "mode:c", "..", "d"));
    assertThat(path.subpath(2, 5), hasSegments(pathFactory, "mode:c", "..", "d"));
    assertThat(path.subpath(3, 5), hasSegments(pathFactory, "..", "d"));
}