@Test public void testGetAncestor() throws Exception { Path path = Path.fromDotString("1.2.3"); Assert.assertThat(path.getAncestor(3), is(Path.fromDotString("1.2.3"))); Assert.assertThat(path.getAncestor(2), is(Path.fromDotString("1.2"))); Assert.assertThat(path.getAncestor(1), is(Path.fromDotString("1"))); Assert.assertThat(path.getAncestor(0), is(Path.fromDotString(""))); }
@Test(expected = IllegalArgumentException.class) public void testGetAncestorIndexGreateThanSize() throws Exception { Path path = Path.fromDotString("1.2.3"); path.getAncestor(5); }
@Test(expected = IllegalArgumentException.class) public void testGetAncestorNegativeIndex() throws Exception { Path path = Path.fromDotString("1.2.3"); path.getAncestor(-1); }