예제 #1
0
  @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("")));
  }
예제 #2
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetAncestorIndexGreateThanSize() throws Exception {
   Path path = Path.fromDotString("1.2.3");
   path.getAncestor(5);
 }
예제 #3
0
 @Test(expected = IllegalArgumentException.class)
 public void testGetAncestorNegativeIndex() throws Exception {
   Path path = Path.fromDotString("1.2.3");
   path.getAncestor(-1);
 }